js/src/gdb/tests/test-jsid.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/gdb/tests/test-jsid.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +#include "gdb-tests.h"
     1.5 +#include "jsapi.h"
     1.6 +
     1.7 +FRAGMENT(jsid, simple) {
     1.8 +  JS::Rooted<JSString *> string(cx, JS_NewStringCopyZ(cx, "moon"));
     1.9 +  JS::Rooted<JSString *> interned(cx, JS_InternJSString(cx, string));
    1.10 +  JS::Rooted<jsid> string_id(cx, INTERNED_STRING_TO_JSID(cx, interned));
    1.11 +  jsid int_id = INT_TO_JSID(1729);
    1.12 +  jsid void_id = JSID_VOID;
    1.13 +  JS::Rooted<jsid> object_id(cx, OBJECT_TO_JSID(JS::CurrentGlobalOrNull(cx)));
    1.14 +
    1.15 +  breakpoint();
    1.16 +
    1.17 +  (void) string;
    1.18 +  (void) interned;
    1.19 +  (void) string_id;
    1.20 +  (void) int_id;
    1.21 +  (void) void_id;
    1.22 +  (void) object_id;
    1.23 +}
    1.24 +
    1.25 +void
    1.26 +jsid_handles(JS::Handle<jsid> jsid_handle,
    1.27 +             JS::MutableHandle<jsid> mutable_jsid_handle)
    1.28 +{
    1.29 +  // Prevent the linker from unifying this function with others that are
    1.30 +  // equivalent in machine code but not type.
    1.31 +  fprintf(stderr, "Called " __FILE__ ":jsid_handles\n");
    1.32 +  breakpoint();
    1.33 +}
    1.34 +
    1.35 +FRAGMENT(jsid, handles) {
    1.36 +  JS::Rooted<JSString *> string(cx, JS_NewStringCopyZ(cx, "shovel"));
    1.37 +  JS::Rooted<JSString *> interned(cx, JS_InternJSString(cx, string));
    1.38 +  JS::Rooted<jsid> string_id(cx, INTERNED_STRING_TO_JSID(cx, interned));
    1.39 +  jsid_handles(string_id, &string_id);
    1.40 +}

mercurial