LCOV - code coverage report
Current view: directory - js/src/jsapi-tests - testIntern.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 20 20 100.0 %
Date: 2012-06-02 Functions: 14 11 78.6 %

       1                 : #include "tests.h"
       2                 : #include "jsatom.h"
       3                 : 
       4                 : #include "vm/String.h"
       5                 : 
       6                 : using namespace mozilla;
       7                 : 
       8               4 : BEGIN_TEST(testAtomizedIsNotInterned)
       9                 : {
      10                 :     /* Try to pick a string that won't be interned by other tests in this runtime. */
      11                 :     static const char someChars[] = "blah blah blah? blah blah blah";
      12               1 :     JSAtom *atom = js_Atomize(cx, someChars, ArrayLength(someChars));
      13               1 :     CHECK(!JS_StringHasBeenInterned(cx, atom));
      14               1 :     CHECK(JS_InternJSString(cx, atom));
      15               1 :     CHECK(JS_StringHasBeenInterned(cx, atom));
      16               1 :     return true;
      17                 : }
      18               1 : END_TEST(testAtomizedIsNotInterned)
      19                 : 
      20                 : struct StringWrapper
      21                 : {
      22                 :     JSString *str;
      23                 :     bool     strOk;
      24                 : } sw;
      25                 : 
      26                 : void
      27               4 : FinalizeCallback(JSContext *cx, JSFinalizeStatus status)
      28                 : {
      29               4 :     if (status == JSFINALIZE_START)
      30               2 :         sw.strOk = !JS_IsAboutToBeFinalized(sw.str);
      31               4 : }
      32                 : 
      33               4 : BEGIN_TEST(testInternAcrossGC)
      34                 : {
      35               1 :     sw.str = JS_InternString(cx, "wrapped chars that another test shouldn't be using");
      36               1 :     sw.strOk = false;
      37               1 :     CHECK(sw.str);
      38               1 :     JS_SetFinalizeCallback(rt, FinalizeCallback);
      39               1 :     JS_GC(cx);
      40               1 :     CHECK(sw.strOk);
      41               1 :     return true;
      42                 : }
      43               3 : END_TEST(testInternAcrossGC)

Generated by: LCOV version 1.7