MCPcopy
hub / github.com/nodejs/node / test

Function test

deps/v8/test/mjsunit/compiler/string-or-oddball-compare.js:35–80  ·  view source on GitHub ↗
(test_fn_src)

Source from the content-addressed store, hash-verified

33}
34
35function test(test_fn_src) {
36 assertEquals(internalized1234, nonInternalized1234);
37 assertTrue(1234123412341234 == nonInternalized1234);
38 assertTrue(%IsInternalizedString(internalized1234));
39 assertFalse(%IsInternalizedString(nonInternalized1234));
40 assertTrue(%IsInternalizedString(internalized1234));
41
42 let test_fn = warmUpTestFn(test_fn_src);
43 assertEquals(1, test_fn("1", "1"));
44 assertOptimized(test_fn);
45
46 assertEquals(0, test_fn(internalized1234, "1"));
47 assertEquals(0, test_fn(undefined, "foo"));
48 assertEquals(0, test_fn("foo", null));
49 assertEquals(0, test_fn(false, "foo"));
50 assertEquals(0, test_fn("foo", true));
51 assertEquals(1, test_fn(undefined, undefined));
52 assertEquals(1, test_fn(null, null));
53 assertEquals(1, test_fn(true, true));
54 assertEquals(1, test_fn(false, false));
55 assertEquals(0, test_fn(undefined, null));
56 assertEquals(0, test_fn(false, true));
57 assertOptimized(test_fn);
58
59 // The GC might have already migrated the thin string, create a new one
60 let thin1234 = %ConstructThinString( "1234" + "1234" + "1234" + "1234");
61 assertFalse(%IsInternalizedString(thin1234));
62
63 assertEquals(1, test_fn(thin1234, "1234123412341234"));
64 assertOptimized(test_fn);
65
66 assertEquals(1, test_fn(thin1234, thin1234));
67 assertOptimized(test_fn);
68
69 assertEquals(1, test_fn(internalized1234, "1234123412341234"));
70 assertOptimized(test_fn);
71
72 // Passing something else than a string or oddball will cause a deopt.
73 assertEquals(0, test_fn(internalized1234, 1234123412341234));
74 assertUnoptimized(test_fn);
75
76 // Non-internalized strings won't cause a deopt.
77 test_fn = warmUpTestFn(test_fn_src);
78 assertEquals(1, test_fn(nonInternalized1234, "1234123412341234"));
79 assertOptimized(test_fn);
80}
81
82function strict_equals_fn(x, y) {
83 if (x === y) {

Callers 1

Calls 4

warmUpTestFnFunction · 0.85
assertEqualsFunction · 0.70
assertTrueFunction · 0.50
assertFalseFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…