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

Function Test

deps/v8/test/debugger/debug/debug-liveedit-literals.js:32–57  ·  view source on GitHub ↗
(old_expression, new_expression)

Source from the content-addressed store, hash-verified

30Debug = debug.Debug
31
32function Test(old_expression, new_expression) {
33 // Generate several instances of function to test that we correctly fix
34 // all functions in memory.
35 var function_instance_number = 11;
36 eval("var t1 =1;\n" +
37 "ChooseAnimalArray = [];\n" +
38 "for (var i = 0; i < function_instance_number; i++) {\n" +
39 " ChooseAnimalArray.push(\n" +
40 " function ChooseAnimal() {\n" +
41 " return " + old_expression + ";\n" +
42 " });\n" +
43 "}\n" +
44 "var t2 =1;\n");
45
46 for (var i = 0; i < ChooseAnimalArray.length; i++) {
47 assertEquals("Cat", ChooseAnimalArray[i]());
48 }
49
50 var new_source =
51 Debug.scriptSource(ChooseAnimalArray[0]).replace(old_expression, new_expression);
52 %LiveEditPatchScript(ChooseAnimalArray[0], new_source);
53
54 for (var i = 0; i < ChooseAnimalArray.length; i++) {
55 assertEquals("Capybara", ChooseAnimalArray[i]());
56 }
57}
58
59// Check that old literal boilerplate was reset.
60Test("['Cat'][0]", "['Capybara'][0]");

Callers 1

Calls 3

scriptSourceMethod · 0.80
evalFunction · 0.50
assertEqualsFunction · 0.50

Tested by

no test coverage detected