MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

deps/v8/test/mjsunit/maglev/string-or-oddball-compare.js:36–81  ·  view source on GitHub ↗
(test_fn_src)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

warmUpMaglevTestFnFunction · 0.70
assertEqualsFunction · 0.50
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…