str-atom-dedupe.js (474B)
1 // Create Latin1 string + atom. 2 var latin1S = "foo".repeat(50); 3 var obj = {}; 4 obj[latin1S] = 3; 5 assertEq(obj[latin1S], 3); 6 7 // Create a TwoByte version, ensure it's in the StringToAtomCache. 8 var twoByteS = newString(latin1S, {twoByte: true}); 9 assertEq(obj[twoByteS], 3); 10 11 // Create a dependent TwoByte string. 12 var depTwoByteS = twoByteS.slice(1); 13 14 // Deduplication shouldn't get confused about Latin1 atom vs TwoByte strings. 15 minorgc(); 16 assertEq(obj["f" + depTwoByteS], 3);