aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-08-11 14:56:33 +0100
committerBen Murdoch <benm@google.com>2010-08-11 14:56:33 +0100
commitbb769b257e753aafcbd96767abb2abc645eaa20c (patch)
treec6fa2c4c5dc62a17135d5e70ba1fd2117ad934e3 /test
parent91e42c979b0b259e6ffa5b3ebc410f47b2bb2cda (diff)
downloadv8-bb769b257e753aafcbd96767abb2abc645eaa20c.tar.gz
Update V8 to r5214 as required by WebKit r65072.
Change-Id: I387277a00cc0949597c0f69a8e4f2da60213c8f2
Diffstat (limited to 'test')
-rw-r--r--test/cctest/test-debug.cc72
-rw-r--r--test/cctest/test-regexp.cc57
-rw-r--r--test/mjsunit/debug-breakpoints.js14
-rw-r--r--test/mjsunit/debug-conditional-breakpoints.js10
-rw-r--r--test/mjsunit/debug-enable-disable-breakpoints.js15
-rw-r--r--test/mjsunit/debug-return-value.js2
-rw-r--r--test/mjsunit/object-freeze.js4
-rw-r--r--test/mjsunit/object-literal.js111
-rw-r--r--test/mjsunit/object-seal.js4
-rw-r--r--test/sputnik/sputnik.status20
10 files changed, 234 insertions, 75 deletions
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 6a94bedb..0455790e 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -1175,11 +1175,11 @@ TEST(BreakPointReturn) {
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, last_source_line);
- CHECK_EQ(16, last_source_column);
+ CHECK_EQ(15, last_source_column);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, last_source_line);
- CHECK_EQ(16, last_source_column);
+ CHECK_EQ(15, last_source_column);
// Run without breakpoints.
ClearBreakPoint(bp);
@@ -1244,7 +1244,9 @@ TEST(GCDuringBreakPointProcessing) {
// Call the function three times with different garbage collections in between
// and make sure that the break point survives.
-static void CallAndGC(v8::Local<v8::Object> recv, v8::Local<v8::Function> f) {
+static void CallAndGC(v8::Local<v8::Object> recv,
+ v8::Local<v8::Function> f,
+ bool force_compaction) {
break_point_hit_count = 0;
for (int i = 0; i < 3; i++) {
@@ -1258,15 +1260,14 @@ static void CallAndGC(v8::Local<v8::Object> recv, v8::Local<v8::Function> f) {
CHECK_EQ(2 + i * 3, break_point_hit_count);
// Mark sweep (and perhaps compact) and call function.
- Heap::CollectAllGarbage(false);
+ Heap::CollectAllGarbage(force_compaction);
f->Call(recv, 0, NULL);
CHECK_EQ(3 + i * 3, break_point_hit_count);
}
}
-// Test that a break point can be set at a return store location.
-TEST(BreakPointSurviveGC) {
+static void TestBreakPointSurviveGC(bool force_compaction) {
break_point_hit_count = 0;
v8::HandleScope scope;
DebugLocalContext env;
@@ -1276,30 +1277,65 @@ TEST(BreakPointSurviveGC) {
v8::Local<v8::Function> foo;
// Test IC store break point with garbage collection.
- foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
- SetBreakPoint(foo, 0);
- CallAndGC(env->Global(), foo);
+ {
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function foo(){}", "foo");
+ foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
+ SetBreakPoint(foo, 0);
+ }
+ CallAndGC(env->Global(), foo, force_compaction);
// Test IC load break point with garbage collection.
- foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
- SetBreakPoint(foo, 0);
- CallAndGC(env->Global(), foo);
+ {
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function foo(){}", "foo");
+ foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
+ SetBreakPoint(foo, 0);
+ }
+ CallAndGC(env->Global(), foo, force_compaction);
// Test IC call break point with garbage collection.
- foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo");
- SetBreakPoint(foo, 0);
- CallAndGC(env->Global(), foo);
+ {
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function foo(){}", "foo");
+ foo = CompileFunction(&env,
+ "function bar(){};function foo(){bar();}",
+ "foo");
+ SetBreakPoint(foo, 0);
+ }
+ CallAndGC(env->Global(), foo, force_compaction);
// Test return break point with garbage collection.
- foo = CompileFunction(&env, "function foo(){}", "foo");
- SetBreakPoint(foo, 0);
- CallAndGC(env->Global(), foo);
+ {
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function foo(){}", "foo");
+ foo = CompileFunction(&env, "function foo(){}", "foo");
+ SetBreakPoint(foo, 0);
+ }
+ CallAndGC(env->Global(), foo, force_compaction);
+
+ // Test non IC break point with garbage collection.
+ {
+ v8::Local<v8::Function> bar =
+ CompileFunction(&env, "function foo(){}", "foo");
+ foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo");
+ SetBreakPoint(foo, 0);
+ }
+ CallAndGC(env->Global(), foo, force_compaction);
+
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
+// Test that a break point can be set at a return store location.
+TEST(BreakPointSurviveGC) {
+ TestBreakPointSurviveGC(false);
+ TestBreakPointSurviveGC(true);
+}
+
+
// Test that break points can be set using the global Debug object.
TEST(BreakPointThroughJavaScript) {
break_point_hit_count = 0;
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 00abab47..186350be 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -1399,7 +1399,8 @@ TEST(LatinCanonicalize) {
for (uc32 c = 128; c < (1 << 21); c++)
CHECK_GE(canonicalize(c), 128);
unibrow::Mapping<unibrow::ToUppercase> to_upper;
- for (uc32 c = 0; c < (1 << 21); c++) {
+ // Canonicalization is only defined for the Basic Multilingual Plane.
+ for (uc32 c = 0; c < (1 << 16); c++) {
unibrow::uchar upper[unibrow::ToUppercase::kMaxWidth];
int length = to_upper.get(c, '\0', upper);
if (length == 0) {
@@ -1414,7 +1415,7 @@ TEST(LatinCanonicalize) {
}
-static uc32 CanonRange(uc32 c) {
+static uc32 CanonRangeEnd(uc32 c) {
unibrow::uchar canon[unibrow::CanonicalizationRange::kMaxWidth];
int count = unibrow::CanonicalizationRange::Convert(c, '\0', canon, NULL);
if (count == 0) {
@@ -1427,47 +1428,29 @@ static uc32 CanonRange(uc32 c) {
TEST(RangeCanonicalization) {
- CHECK_NE(CanonRange(0) & CharacterRange::kStartMarker, 0);
// Check that we arrive at the same result when using the basic
// range canonicalization primitives as when using immediate
// canonicalization.
unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize;
- for (int i = 0; i < CharacterRange::kRangeCanonicalizeMax; i++) {
- int range = CanonRange(i);
- int indirect_length = 0;
- unibrow::uchar indirect[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- if ((range & CharacterRange::kStartMarker) == 0) {
- indirect_length = un_canonicalize.get(i - range, '\0', indirect);
- for (int i = 0; i < indirect_length; i++)
- indirect[i] += range;
- } else {
- indirect_length = un_canonicalize.get(i, '\0', indirect);
- }
- unibrow::uchar direct[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int direct_length = un_canonicalize.get(i, '\0', direct);
- CHECK_EQ(direct_length, indirect_length);
- }
- // Check that we arrive at the same results when skipping over
- // canonicalization ranges.
- int next_block = 0;
- while (next_block < CharacterRange::kRangeCanonicalizeMax) {
- uc32 start = CanonRange(next_block);
- CHECK_NE((start & CharacterRange::kStartMarker), 0);
- unsigned dist = start & CharacterRange::kPayloadMask;
- unibrow::uchar first[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int first_length = un_canonicalize.get(next_block, '\0', first);
- for (unsigned i = 1; i < dist; i++) {
- CHECK_EQ(i, CanonRange(next_block + i));
- unibrow::uchar succ[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int succ_length = un_canonicalize.get(next_block + i, '\0', succ);
- CHECK_EQ(first_length, succ_length);
- for (int j = 0; j < succ_length; j++) {
- int calc = first[j] + i;
- int found = succ[j];
- CHECK_EQ(calc, found);
+ int block_start = 0;
+ while (block_start <= 0xFFFF) {
+ uc32 block_end = CanonRangeEnd(block_start);
+ unsigned block_length = block_end - block_start + 1;
+ if (block_length > 1) {
+ unibrow::uchar first[unibrow::Ecma262UnCanonicalize::kMaxWidth];
+ int first_length = un_canonicalize.get(block_start, '\0', first);
+ for (unsigned i = 1; i < block_length; i++) {
+ unibrow::uchar succ[unibrow::Ecma262UnCanonicalize::kMaxWidth];
+ int succ_length = un_canonicalize.get(block_start + i, '\0', succ);
+ CHECK_EQ(first_length, succ_length);
+ for (int j = 0; j < succ_length; j++) {
+ int calc = first[j] + i;
+ int found = succ[j];
+ CHECK_EQ(calc, found);
+ }
}
}
- next_block = next_block + dist;
+ block_start = block_start + block_length;
}
}
diff --git a/test/mjsunit/debug-breakpoints.js b/test/mjsunit/debug-breakpoints.js
index c332f1e1..0bc349c4 100644
--- a/test/mjsunit/debug-breakpoints.js
+++ b/test/mjsunit/debug-breakpoints.js
@@ -43,12 +43,12 @@ bp1 = Debug.setBreakPoint(f, 0, 8);
assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f));
bp2 = Debug.setBreakPoint(f, 0, 4);
assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f));
-bp3 = Debug.setBreakPoint(f, 0, 12);
-assertEquals("() {[B0]a=1;[B1]b=2}[B2]", Debug.showBreakPoints(f));
+bp3 = Debug.setBreakPoint(f, 0, 11);
+assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp1);
-assertEquals("() {[B0]a=1;b=2}[B1]", Debug.showBreakPoints(f));
+assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp2);
-assertEquals("() {a=1;b=2}[B0]", Debug.showBreakPoints(f));
+assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp3);
assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f));
@@ -96,21 +96,21 @@ bp3 = Debug.setBreakPoint(g, 3, 0);
// }[B2]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0);
-assertTrue(Debug.showBreakPoints(g).indexOf("}[B2]") > 0);
+assertTrue(Debug.showBreakPoints(g).indexOf("[B2]}") > 0);
Debug.clearBreakPoint(bp1);
// function g() {
// [B0]a=1;
// b=2;
// }[B1]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
-assertTrue(Debug.showBreakPoints(g).indexOf("}[B1]") > 0);
+assertTrue(Debug.showBreakPoints(g).indexOf("[B1]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0);
Debug.clearBreakPoint(bp2);
// function g() {
// a=1;
// b=2;
// }[B0]
-assertTrue(Debug.showBreakPoints(g).indexOf("}[B0]") > 0);
+assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0);
Debug.clearBreakPoint(bp3);
// function g() {
diff --git a/test/mjsunit/debug-conditional-breakpoints.js b/test/mjsunit/debug-conditional-breakpoints.js
index bd4cdd15..62484373 100644
--- a/test/mjsunit/debug-conditional-breakpoints.js
+++ b/test/mjsunit/debug-conditional-breakpoints.js
@@ -136,7 +136,7 @@ Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks a local variable.
break_point_hit_count = 0;
-bp = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0');
+bp = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
for (var i = 0; i < 10; i++) {
g();
}
@@ -146,8 +146,8 @@ Debug.clearBreakPoint(bp);
// Multiple conditional breakpoint which the same condition.
break_point_hit_count = 0;
-bp1 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0');
-bp2 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0');
+bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
+bp2 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
for (var i = 0; i < 10; i++) {
g();
}
@@ -159,8 +159,8 @@ Debug.clearBreakPoint(bp2);
// Multiple conditional breakpoint which different conditions.
break_point_hit_count = 0;
-bp1 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0');
-bp2 = Debug.setBreakPoint(h, 0, 23, '(a + 1) % 2 == 0');
+bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
+bp2 = Debug.setBreakPoint(h, 0, 22, '(a + 1) % 2 == 0');
for (var i = 0; i < 10; i++) {
g();
}
diff --git a/test/mjsunit/debug-enable-disable-breakpoints.js b/test/mjsunit/debug-enable-disable-breakpoints.js
index 071397be..4592ffcc 100644
--- a/test/mjsunit/debug-enable-disable-breakpoints.js
+++ b/test/mjsunit/debug-enable-disable-breakpoints.js
@@ -88,3 +88,18 @@ assertEquals(5, break_point_hit_count);
Debug.disableBreakPoint(bp1);
f();
assertEquals(6, break_point_hit_count);
+
+// Deactivate all breakpoints.
+Debug.debuggerFlags().breakPointsActive.setValue(false);
+f();
+assertEquals(6, break_point_hit_count);
+
+// Enable the first breakpoint.
+Debug.enableBreakPoint(bp1);
+f();
+assertEquals(6, break_point_hit_count);
+
+// Activate all breakpoints.
+Debug.debuggerFlags().breakPointsActive.setValue(true);
+f();
+assertEquals(7, break_point_hit_count);
diff --git a/test/mjsunit/debug-return-value.js b/test/mjsunit/debug-return-value.js
index a9ac5204..3982ea91 100644
--- a/test/mjsunit/debug-return-value.js
+++ b/test/mjsunit/debug-return-value.js
@@ -101,7 +101,7 @@ function listener(event, exec_state, event_data, data) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
} else {
// Position at the end of the function.
- assertEquals(debugger_source_position + 51,
+ assertEquals(debugger_source_position + 50,
exec_state.frame(0).sourcePosition());
// Just about to return from the function.
diff --git a/test/mjsunit/object-freeze.js b/test/mjsunit/object-freeze.js
index 5ab45e1f..15e19abb 100644
--- a/test/mjsunit/object-freeze.js
+++ b/test/mjsunit/object-freeze.js
@@ -191,3 +191,7 @@ Object.defineProperty(obj5, 'y', {configurable: false, writable: false});
Object.preventExtensions(obj5);
assertFalse(Object.isFrozen(obj5));
+
+// Make sure that Object.freeze returns the frozen object.
+var obj6 = {}
+assertTrue(obj6 === Object.freeze(obj6))
diff --git a/test/mjsunit/object-literal.js b/test/mjsunit/object-literal.js
index cc6f59dc..0ad1968e 100644
--- a/test/mjsunit/object-literal.js
+++ b/test/mjsunit/object-literal.js
@@ -95,11 +95,118 @@ function makeRegexpInArray() { return [ [ /a*/, {} ] ]; }
a = makeRegexpInArray();
var b = makeRegexpInArray();
-assertTrue(a[0][0] === b[0][0]);
+assertFalse(a[0][0] === b[0][0]);
assertFalse(a[0][1] === b[0][1]);
function makeRegexpInObject() { return { a: { b: /b*/, c: {} } }; }
a = makeRegexpInObject();
b = makeRegexpInObject();
-assertTrue(a.a.b === b.a.b);
+assertFalse(a.a.b === b.a.b);
assertFalse(a.a.c === b.a.c);
+
+
+// Test keywords valid as property names in initializers and dot-access.
+var keywords = [
+ "break",
+ "case",
+ "catch",
+ "const",
+ "continue",
+ "debugger",
+ "default",
+ "delete",
+ "do",
+ "else",
+ "false",
+ "finally",
+ "for",
+ "function",
+ "if",
+ "in",
+ "instanceof",
+ "native",
+ "new",
+ "null",
+ "return",
+ "switch",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "typeof",
+ "var",
+ "void",
+ "while",
+ "with",
+];
+
+function testKeywordProperty(keyword) {
+ try {
+ // Sanity check that what we get is a keyword.
+ eval("var " + keyword + " = 42;");
+ assertUnreachable("Not a keyword: " + keyword);
+ } catch (e) { }
+
+ // Simple property, read and write.
+ var x = eval("({" + keyword + ": 42})");
+ assertEquals(42, x[keyword]);
+ assertEquals(42, eval("x." + keyword));
+ eval("x." + keyword + " = 37");
+ assertEquals(37, x[keyword]);
+ assertEquals(37, eval("x." + keyword));
+
+ // Getter/setter property, read and write.
+ var y = eval("({value : 42, get " + keyword + "(){return this.value}," +
+ " set " + keyword + "(v) { this.value = v; }})");
+ assertEquals(42, y[keyword]);
+ assertEquals(42, eval("y." + keyword));
+ eval("y." + keyword + " = 37");
+ assertEquals(37, y[keyword]);
+ assertEquals(37, eval("y." + keyword));
+
+ // Quoted keyword works is read back by unquoted as well.
+ var z = eval("({\"" + keyword + "\": 42})");
+ assertEquals(42, z[keyword]);
+ assertEquals(42, eval("z." + keyword));
+
+ // Function property, called.
+ var was_called;
+ function test_call() { this.was_called = true; was_called = true; }
+ var w = eval("({" + keyword + ": test_call, was_called: false})");
+ eval("w." + keyword + "();");
+ assertTrue(was_called);
+ assertTrue(w.was_called);
+
+ // Function property, constructed.
+ function construct() { this.constructed = true; }
+ var v = eval("({" + keyword + ": construct})");
+ var vo = eval("new v." + keyword + "()");
+ assertTrue(vo instanceof construct);
+ assertTrue(vo.constructed);
+}
+
+for (var i = 0; i < keywords.length; i++) {
+ testKeywordProperty(keywords[i]);
+}
+
+// Test getter and setter properties with string/number literal names.
+
+var obj = {get 42() { return 42; },
+ get 3.14() { return "PI"; },
+ get "PI"() { return 3.14; },
+ readback: 0,
+ set 37(v) { this.readback = v; },
+ set 1.44(v) { this.readback = v; },
+ set "Poo"(v) { this.readback = v; }}
+
+assertEquals(42, obj[42]);
+assertEquals("PI", obj[3.14]);
+assertEquals(3.14, obj["PI"]);
+obj[37] = "t1";
+assertEquals("t1", obj.readback);
+obj[1.44] = "t2";
+assertEquals("t2", obj.readback);
+obj["Poo"] = "t3";
+assertEquals("t3", obj.readback);
+
+
diff --git a/test/mjsunit/object-seal.js b/test/mjsunit/object-seal.js
index 896411ca..9e7f44b9 100644
--- a/test/mjsunit/object-seal.js
+++ b/test/mjsunit/object-seal.js
@@ -193,3 +193,7 @@ Object.defineProperty(obj4, 'y', {configurable: false, writable: false});
Object.preventExtensions(obj4);
assertFalse(Object.isSealed(obj4));
+
+// Make sure that Object.seal returns the sealed object.
+var obj4 = {}
+assertTrue(obj4 === Object.seal(obj4))
diff --git a/test/sputnik/sputnik.status b/test/sputnik/sputnik.status
index 4c6fd1e6..13108c0f 100644
--- a/test/sputnik/sputnik.status
+++ b/test/sputnik/sputnik.status
@@ -158,11 +158,6 @@ S15.5.4.11_D1.1_T1: PASS || FAIL_OK
S15.5.4.11_D1.1_T3: PASS || FAIL_OK
S12.6.4_D1: PASS || FAIL_OK
-# We deliberately don't throw type errors when iterating through the
-# undefined object
-S9.9_A1: FAIL_OK
-S9.9_A2: FAIL_OK
-
# We allow function declarations within statements
S12.5_A9_T1: FAIL_OK
S12.5_A9_T2: FAIL_OK
@@ -184,6 +179,21 @@ S15.3.4.2_A1_T1: FAIL_OK
S8.5_A2.2: PASS, FAIL if $system == linux, FAIL if $system == macos
S8.5_A2.1: PASS, FAIL if $system == linux, FAIL if $system == macos
+##################### ES3 TESTS #########################
+# These tests check for ES3 semantics, and differ from ES5.
+# When we follow ES5 semantics, it's ok to fail the test.
+
+# Allow keywords as names of properties in object initialisers and
+# in dot-notation property access.
+S11.1.5_A4.1: FAIL_OK
+S11.1.5_A4.2: FAIL_OK
+
+# Don't throw type errors when iterating through the undefined object.
+S9.9_A1: FAIL_OK
+S9.9_A2: FAIL_OK
+
+
+
##################### SKIPPED TESTS #####################
# These tests take a looong time to run in debug mode.