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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/gdb/tests/test-JSString.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +#include "gdb-tests.h"
     1.5 +#include "jsatom.h"
     1.6 +#include "jscntxt.h"
     1.7 +
     1.8 +// When JSGC_ANALYSIS is #defined, Rooted<JSFlatString*> needs the definition
     1.9 +// of JSFlatString in order to figure out its ThingRootKind
    1.10 +#include "vm/String.h"
    1.11 +
    1.12 +FRAGMENT(JSString, simple) {
    1.13 +  JS::Rooted<JSString *> empty(cx, JS_NewStringCopyN(cx, nullptr, 0));
    1.14 +  JS::Rooted<JSString *> x(cx, JS_NewStringCopyN(cx, "x", 1));
    1.15 +  JS::Rooted<JSString *> z(cx, JS_NewStringCopyZ(cx, "z"));
    1.16 +
    1.17 +  // I expect this will be a non-inlined string.
    1.18 +  JS::Rooted<JSString *> stars(cx, JS_NewStringCopyZ(cx,
    1.19 +                                                     "*************************"
    1.20 +                                                     "*************************"
    1.21 +                                                     "*************************"
    1.22 +                                                     "*************************"));
    1.23 +
    1.24 +  // This may well be an inlined string.
    1.25 +  JS::Rooted<JSString *> xz(cx, JS_ConcatStrings(cx, x, z));
    1.26 +
    1.27 +  // This will probably be a rope.
    1.28 +  JS::Rooted<JSString *> doubleStars(cx, JS_ConcatStrings(cx, stars, stars));
    1.29 +
    1.30 +  // Ensure we're not confused by typedefs for pointer types.
    1.31 +  JSString *xRaw = x;
    1.32 +
    1.33 +  breakpoint();
    1.34 +
    1.35 +  (void) empty;
    1.36 +  (void) x;
    1.37 +  (void) z;
    1.38 +  (void) stars;
    1.39 +  (void) xz;
    1.40 +  (void) doubleStars;
    1.41 +  (void) xRaw;
    1.42 +}
    1.43 +
    1.44 +FRAGMENT(JSString, null) {
    1.45 +  JS::Rooted<JSString *> null(cx, nullptr);
    1.46 +  JSString *nullRaw = null;
    1.47 +
    1.48 +  breakpoint();
    1.49 +
    1.50 +  (void) null;
    1.51 +  (void) nullRaw;
    1.52 +}
    1.53 +
    1.54 +FRAGMENT(JSString, subclasses) {
    1.55 +  JS::Rooted<JSFlatString *> flat(cx, JS_FlattenString(cx, JS_NewStringCopyZ(cx, "Hi!")));
    1.56 +
    1.57 +  breakpoint();
    1.58 +
    1.59 +  (void) flat;
    1.60 +}
    1.61 +
    1.62 +FRAGMENT(JSString, atom) {
    1.63 +  JSAtom *molybdenum = js::Atomize(cx, "molybdenum", 10);
    1.64 +  breakpoint();
    1.65 +
    1.66 +  (void) molybdenum;
    1.67 +}

mercurial