Debian Codegraph @

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

raw
1 #include "gdb-tests.h"
2
3 #include "vm/JSContext.h"
4 // When JSGC_ANALYSIS is #defined, Rooted<JSLinearString*> needs the definition
5 // of JSLinearString in order to figure out its ThingRootKind
6 #include "vm/StringType.h"
7
8 FRAGMENT(JSString, simple) {
9 JS::Rooted<JSString*> empty(cx, JS_NewStringCopyN(cx, nullptr, 0));
10 JS::Rooted<JSString*> x(cx, JS_NewStringCopyN(cx, "x", 1));
11 JS::Rooted<JSString*> z(cx, JS_NewStringCopyZ(cx, "z"));
12
13 // I expect this will be a non-inlined string.
14 JS::Rooted<JSString*> stars(cx,
15 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 use(empty);
33 use(x);
34 use(z);
35 use(stars);
36 use(xz);
37 use(doubleStars);
38 use(xRaw);
39 }
40
41 FRAGMENT(JSString, null) {
42 JS::Rooted<JSString*> null(cx, nullptr);
43 JSString* nullRaw = null;
44
45 breakpoint();
46
47 use(null);
48 use(nullRaw);
49 }
50
51 FRAGMENT(JSString, subclasses) {
52 JS::Rooted<JSLinearString*> linear(
53 cx, JS_EnsureLinearString(cx, JS_NewStringCopyZ(cx, "Hi!")));
54
55 breakpoint();
56
57 use(linear);
58 }
59
60 FRAGMENT(JSString, atom) {
61 JSAtom* molybdenum = js::Atomize(cx, "molybdenum", 10);
62 breakpoint();
63
64 use(molybdenum);
65 }