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

LCOV - code coverage report
| Current view: | directory - js/src/jsapi-tests - testValueABI.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 15 | 15 | 100.0 %
| Date: | 2012-04-07 | Functions: | 13 | 10 | 76.9 %

           1                 : #include "tests.h"
           2                 :
           3                 : /*
           4                 :  * Bug 689101 - jsval is technically a non-POD type because it has a private
           5                 :  * data member. On gcc, this doesn't seem to matter. On MSVC, this prevents
           6                 :  * returning a jsval from a function between C and C++ because it will use a
           7                 :  * retparam in C++ and a direct return value in C.
           8                 :  *
           9                 :  * Bug 712289 - jsval alignment was different on 32-bit platforms between C and
          10                 :  * C++ because the default alignments of js::Value and jsval_layout differ.
          11                 :  */
          12                 :
          13                 : extern "C" {
          14                 :
          15                 : extern JSBool
          16                 : C_ValueToObject(JSContext *cx, jsval v, JSObject **obj);
          17                 :
          18                 : extern jsval
          19                 : C_GetEmptyStringValue(JSContext *cx);
          20                 :
          21                 : extern size_t
          22                 : C_jsvalAlignmentTest();
          23                 :
          24                 : }
          25                 :
          26               4 : BEGIN_TEST(testValueABI_retparam)
          27                 : {
          28               1 :     JSObject* obj = JS_GetGlobalObject(cx);
          29               1 :     jsval v = OBJECT_TO_JSVAL(obj);
          30               1 :     obj = NULL;
          31               1 :     CHECK(C_ValueToObject(cx, v, &obj));
          32                 :     JSBool equal;
          33               1 :     CHECK(JS_StrictlyEqual(cx, v, OBJECT_TO_JSVAL(obj), &equal));
          34               1 :     CHECK(equal);
          35                 :
          36               1 :     v = C_GetEmptyStringValue(cx);
          37               1 :     CHECK(JSVAL_IS_STRING(v));
          38                 :
          39               1 :     return true;
          40                 : }
          41               1 : END_TEST(testValueABI_retparam)
          42                 :
          43               4 : BEGIN_TEST(testValueABI_alignment)
          44                 : {
          45                 :     typedef struct { char c; jsval v; } AlignTest;
          46               1 :     CHECK(C_jsvalAlignmentTest() == sizeof(AlignTest));
          47                 :
          48               1 :     return true;
          49                 : }
          50               3 : END_TEST(testValueABI_alignment)

Generated by: LCOV version 1.7