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

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

mercurial