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

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 #include "gdb-tests.h"
michael@0 2 #include "jsatom.h"
michael@0 3 #include "jscntxt.h"
michael@0 4
michael@0 5 // When JSGC_ANALYSIS is #defined, Rooted<JSFlatString*> needs the definition
michael@0 6 // of JSFlatString in order to figure out its ThingRootKind
michael@0 7 #include "vm/String.h"
michael@0 8
michael@0 9 FRAGMENT(JSString, simple) {
michael@0 10 JS::Rooted<JSString *> empty(cx, JS_NewStringCopyN(cx, nullptr, 0));
michael@0 11 JS::Rooted<JSString *> x(cx, JS_NewStringCopyN(cx, "x", 1));
michael@0 12 JS::Rooted<JSString *> z(cx, JS_NewStringCopyZ(cx, "z"));
michael@0 13
michael@0 14 // I expect this will be a non-inlined string.
michael@0 15 JS::Rooted<JSString *> stars(cx, JS_NewStringCopyZ(cx,
michael@0 16 "*************************"
michael@0 17 "*************************"
michael@0 18 "*************************"
michael@0 19 "*************************"));
michael@0 20
michael@0 21 // This may well be an inlined string.
michael@0 22 JS::Rooted<JSString *> xz(cx, JS_ConcatStrings(cx, x, z));
michael@0 23
michael@0 24 // This will probably be a rope.
michael@0 25 JS::Rooted<JSString *> doubleStars(cx, JS_ConcatStrings(cx, stars, stars));
michael@0 26
michael@0 27 // Ensure we're not confused by typedefs for pointer types.
michael@0 28 JSString *xRaw = x;
michael@0 29
michael@0 30 breakpoint();
michael@0 31
michael@0 32 (void) empty;
michael@0 33 (void) x;
michael@0 34 (void) z;
michael@0 35 (void) stars;
michael@0 36 (void) xz;
michael@0 37 (void) doubleStars;
michael@0 38 (void) xRaw;
michael@0 39 }
michael@0 40
michael@0 41 FRAGMENT(JSString, null) {
michael@0 42 JS::Rooted<JSString *> null(cx, nullptr);
michael@0 43 JSString *nullRaw = null;
michael@0 44
michael@0 45 breakpoint();
michael@0 46
michael@0 47 (void) null;
michael@0 48 (void) nullRaw;
michael@0 49 }
michael@0 50
michael@0 51 FRAGMENT(JSString, subclasses) {
michael@0 52 JS::Rooted<JSFlatString *> flat(cx, JS_FlattenString(cx, JS_NewStringCopyZ(cx, "Hi!")));
michael@0 53
michael@0 54 breakpoint();
michael@0 55
michael@0 56 (void) flat;
michael@0 57 }
michael@0 58
michael@0 59 FRAGMENT(JSString, atom) {
michael@0 60 JSAtom *molybdenum = js::Atomize(cx, "molybdenum", 10);
michael@0 61 breakpoint();
michael@0 62
michael@0 63 (void) molybdenum;
michael@0 64 }

mercurial