LCOV - app.info - js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp

LCOV - code coverage report
| Current view: | directory - js/src/jsapi-tests - testDefineGetterSetterNonEnumerable.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 29 | 27 | 93.1 %
| Date: | 2012-04-07 | Functions: | 9 | 6 | 66.7 %

           1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
           2                 :  * vim: set ts=8 sw=4 et tw=99:
           3                 :  */
           4                 :
           5                 : #include "tests.h"
           6                 :
           7                 : static JSBool
           8               0 : native(JSContext *cx, unsigned argc, jsval *vp)
           9                 : {
          10               0 :     return JS_TRUE;
          11                 : }
          12                 :
          13                 : static const char PROPERTY_NAME[] = "foo";
          14                 :
          15               4 : BEGIN_TEST(testDefineGetterSetterNonEnumerable)
          16                 : {
          17               2 :     jsvalRoot vobj(cx);
          18               1 :     JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
          19               1 :     CHECK(obj);
          20               1 :     vobj = OBJECT_TO_JSVAL(obj);
          21                 :
          22               2 :     jsvalRoot vget(cx);
          23               1 :     JSFunction *funGet = JS_NewFunction(cx, native, 0, 0, NULL, "get");
          24               1 :     CHECK(funGet);
          25               1 :     JSObject *funGetObj = JS_GetFunctionObject(funGet);
          26               1 :     vget = OBJECT_TO_JSVAL(funGetObj);
          27                 :
          28               2 :     jsvalRoot vset(cx);
          29               1 :     JSFunction *funSet = JS_NewFunction(cx, native, 1, 0, NULL, "set");
          30               1 :     CHECK(funSet);
          31               1 :     JSObject *funSetObj = JS_GetFunctionObject(funSet);
          32               1 :     vset = OBJECT_TO_JSVAL(funSetObj);
          33                 :
          34               1 :     CHECK(JS_DefineProperty(cx, JSVAL_TO_OBJECT(vobj), PROPERTY_NAME,
          35                 :                             JSVAL_VOID,
          36                 :                             JS_DATA_TO_FUNC_PTR(JSPropertyOp, funGetObj),
          37                 :                             JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, funSetObj),
          38                 :                             JSPROP_GETTER | JSPROP_SETTER | JSPROP_ENUMERATE));
          39                 :
          40               1 :     CHECK(JS_DefineProperty(cx, JSVAL_TO_OBJECT(vobj), PROPERTY_NAME,
          41                 :                             JSVAL_VOID,
          42                 :                             JS_DATA_TO_FUNC_PTR(JSPropertyOp, funGetObj),
          43                 :                             JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, funSetObj),
          44                 :                             JSPROP_GETTER | JSPROP_SETTER | JSPROP_PERMANENT));
          45                 :
          46               1 :     JSBool found = JS_FALSE;
          47               1 :     unsigned attrs = 0;
          48               1 :     CHECK(JS_GetPropertyAttributes(cx, JSVAL_TO_OBJECT(vobj), PROPERTY_NAME,
          49                 :                                    &attrs, &found));
          50               1 :     CHECK(found);
          51               1 :     CHECK(attrs & JSPROP_GETTER);
          52               1 :     CHECK(attrs & JSPROP_SETTER);
          53               1 :     CHECK(attrs & JSPROP_PERMANENT);
          54               1 :     CHECK(!(attrs & JSPROP_ENUMERATE));
          55                 :
          56               1 :     return true;
          57                 : }
          58               2 : END_TEST(testDefineGetterSetterNonEnumerable)

Generated by: LCOV version 1.7