aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cctest/test-debug.cc45
-rw-r--r--test/cctest/test-lock.cc1
-rwxr-xr-xtest/cctest/test-parsing.cc33
-rw-r--r--test/cctest/test-regexp.cc13
-rw-r--r--test/cctest/test-serialize.cc6
-rw-r--r--test/mjsunit/debug-compile-event.js18
-rw-r--r--test/mjsunit/mirror-script.js4
-rw-r--r--test/mjsunit/mjsunit.status9
-rw-r--r--test/mjsunit/object-literal-conversions.js46
-rw-r--r--test/mjsunit/object-literal-overwrite.js118
-rw-r--r--test/mjsunit/regress/regress-conditional-position.js95
-rw-r--r--test/mjsunit/string-externalize.js6
-rw-r--r--test/mjsunit/string-replace-with-empty.js64
-rw-r--r--test/mjsunit/string-split.js91
14 files changed, 428 insertions, 121 deletions
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index d59e2f5a..748e3e8d 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -902,6 +902,7 @@ static void DebugEventBreak(v8::DebugEvent event,
// Debug event handler which re-issues a debug break until a limit has been
// reached.
int max_break_point_hit_count = 0;
+bool terminate_after_max_break_point_hit = false;
static void DebugEventBreakMax(v8::DebugEvent event,
v8::Handle<v8::Object> exec_state,
v8::Handle<v8::Object> event_data,
@@ -909,12 +910,17 @@ static void DebugEventBreakMax(v8::DebugEvent event,
// When hitting a debug event listener there must be a break set.
CHECK_NE(v8::internal::Debug::break_id(), 0);
- if (event == v8::Break && break_point_hit_count < max_break_point_hit_count) {
- // Count the number of breaks.
- break_point_hit_count++;
+ if (event == v8::Break) {
+ if (break_point_hit_count < max_break_point_hit_count) {
+ // Count the number of breaks.
+ break_point_hit_count++;
- // Set the break flag again to come back here as soon as possible.
- v8::Debug::DebugBreak();
+ // Set the break flag again to come back here as soon as possible.
+ v8::Debug::DebugBreak();
+ } else if (terminate_after_max_break_point_hit) {
+ // Terminate execution after the last break if requested.
+ v8::V8::TerminateExecution();
+ }
}
}
@@ -6892,4 +6898,33 @@ TEST(DebugEventBreakData) {
CheckDebuggerUnloaded();
}
+
+// Test that setting the terminate execution flag during debug break processing.
+TEST(DebugBreakLoop) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Receive 100 breaks and terminate.
+ max_break_point_hit_count = 100;
+ terminate_after_max_break_point_hit = true;
+
+ // Register a debug event listener which sets the break flag and counts.
+ v8::Debug::SetDebugEventListener(DebugEventBreakMax);
+
+ // Function with infinite loop.
+ CompileRun("function f() { while (true) { } }");
+
+ // Set the debug break to enter the debugger as soon as possible.
+ v8::Debug::DebugBreak();
+
+ // Call function with infinite loop.
+ CompileRun("f();");
+ CHECK_EQ(100, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
#endif // ENABLE_DEBUGGER_SUPPORT
diff --git a/test/cctest/test-lock.cc b/test/cctest/test-lock.cc
index 5eecfcee..9039e022 100644
--- a/test/cctest/test-lock.cc
+++ b/test/cctest/test-lock.cc
@@ -60,4 +60,5 @@ TEST(SemaphoreTimeout) {
sem->Signal();
ok = sem->Wait(1000);
CHECK(ok);
+ delete sem;
}
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 02503f22..7ae8dcfa 100755
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
+#include <stdio.h>
#include "v8.h"
@@ -34,7 +35,8 @@
#include "parser.h"
#include "utils.h"
#include "execution.h"
-
+#include "scanner.h"
+#include "preparser.h"
#include "cctest.h"
namespace i = ::v8::internal;
@@ -239,3 +241,32 @@ TEST(Preparsing) {
i::Vector<const char*> args = pre_impl->BuildArgs();
CHECK_GT(strlen(message), 0);
}
+
+
+TEST(StandAlonePreParser) {
+ int marker;
+ i::StackGuard::SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ const char* programs[] = {
+ "{label: 42}",
+ "var x = 42;",
+ "function foo(x, y) { return x + y; }",
+ "native function foo(); return %ArgleBargle(glop);",
+ "var x = new new Function('this.x = 42');",
+ NULL
+ };
+
+ for (int i = 0; programs[i]; i++) {
+ const char* program = programs[i];
+ unibrow::Utf8InputBuffer<256> stream(program, strlen(program));
+ i::CompleteParserRecorder log;
+ i::Scanner scanner;
+ scanner.Initialize(i::Handle<i::String>::null(), &stream, i::JAVASCRIPT);
+ v8::preparser::PreParser<i::Scanner, i::CompleteParserRecorder> preparser;
+ bool result = preparser.PreParseProgram(&scanner, &log, true);
+ CHECK(result);
+ i::ScriptDataImpl data(log.ExtractData());
+ CHECK(!data.has_error());
+ }
+}
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 11a808e3..3e6709ae 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -64,7 +64,7 @@ static bool CheckParse(const char* input) {
ZoneScope zone_scope(DELETE_ON_EXIT);
FlatStringReader reader(CStrVector(input));
RegExpCompileData result;
- return v8::internal::Parser::ParseRegExp(&reader, false, &result);
+ return v8::internal::RegExpParser::ParseRegExp(&reader, false, &result);
}
@@ -74,7 +74,7 @@ static SmartPointer<const char> Parse(const char* input) {
ZoneScope zone_scope(DELETE_ON_EXIT);
FlatStringReader reader(CStrVector(input));
RegExpCompileData result;
- CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
+ CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
SmartPointer<const char> output = result.tree->ToString();
@@ -88,7 +88,7 @@ static bool CheckSimple(const char* input) {
ZoneScope zone_scope(DELETE_ON_EXIT);
FlatStringReader reader(CStrVector(input));
RegExpCompileData result;
- CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
+ CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
return result.simple;
@@ -106,7 +106,7 @@ static MinMaxPair CheckMinMaxMatch(const char* input) {
ZoneScope zone_scope(DELETE_ON_EXIT);
FlatStringReader reader(CStrVector(input));
RegExpCompileData result;
- CHECK(v8::internal::Parser::ParseRegExp(&reader, false, &result));
+ CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
int min_match = result.tree->min_match();
@@ -365,7 +365,7 @@ static void ExpectError(const char* input,
ZoneScope zone_scope(DELETE_ON_EXIT);
FlatStringReader reader(CStrVector(input));
RegExpCompileData result;
- CHECK_EQ(false, v8::internal::Parser::ParseRegExp(&reader, false, &result));
+ CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
CHECK(result.tree == NULL);
CHECK(!result.error.is_null());
SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS);
@@ -473,7 +473,8 @@ static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) {
V8::Initialize(NULL);
FlatStringReader reader(CStrVector(input));
RegExpCompileData compile_data;
- if (!v8::internal::Parser::ParseRegExp(&reader, multiline, &compile_data))
+ if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
+ &compile_data))
return NULL;
Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input));
RegExpEngine::Compile(&compile_data, false, multiline, pattern, is_ascii);
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 6a513e5f..1cbaf2bf 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -216,6 +216,7 @@ void FileByteSink::WriteSpaceUsed(
Vector<char> name = Vector<char>::New(file_name_length + 1);
OS::SNPrintF(name, "%s.size", file_name_);
FILE* fp = OS::FOpen(name.start(), "w");
+ name.Dispose();
fprintf(fp, "new %d\n", new_space_used);
fprintf(fp, "pointer %d\n", pointer_space_used);
fprintf(fp, "data %d\n", data_space_used);
@@ -381,6 +382,7 @@ TEST(PartialSerialization) {
env.Dispose();
FileByteSink startup_sink(startup_name.start());
+ startup_name.Dispose();
StartupSerializer startup_serializer(&startup_sink);
startup_serializer.SerializeStrongReferences();
@@ -403,6 +405,7 @@ static void ReserveSpaceForPartialSnapshot(const char* file_name) {
Vector<char> name = Vector<char>::New(file_name_length + 1);
OS::SNPrintF(name, "%s.size", file_name);
FILE* fp = OS::FOpen(name.start(), "r");
+ name.Dispose();
int new_size, pointer_size, data_size, code_size, map_size, cell_size;
int large_size;
#ifdef _MSC_VER
@@ -438,6 +441,7 @@ DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
CHECK(Snapshot::Initialize(startup_name.start()));
+ startup_name.Dispose();
const char* file_name = FLAG_testing_serialization_file;
ReserveSpaceForPartialSnapshot(file_name);
@@ -495,6 +499,7 @@ TEST(ContextSerialization) {
env.Dispose();
FileByteSink startup_sink(startup_name.start());
+ startup_name.Dispose();
StartupSerializer startup_serializer(&startup_sink);
startup_serializer.SerializeStrongReferences();
@@ -519,6 +524,7 @@ DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
CHECK(Snapshot::Initialize(startup_name.start()));
+ startup_name.Dispose();
const char* file_name = FLAG_testing_serialization_file;
ReserveSpaceForPartialSnapshot(file_name);
diff --git a/test/mjsunit/debug-compile-event.js b/test/mjsunit/debug-compile-event.js
index e7ecf47e..b00a907a 100644
--- a/test/mjsunit/debug-compile-event.js
+++ b/test/mjsunit/debug-compile-event.js
@@ -36,7 +36,6 @@ var current_source = ''; // Current source being compiled.
var source_count = 0; // Total number of scources compiled.
var host_compilations = 0; // Number of scources compiled through the API.
var eval_compilations = 0; // Number of scources compiled through eval.
-var json_compilations = 0; // Number of scources compiled through JSON.parse.
function compileSource(source) {
@@ -62,9 +61,6 @@ function listener(event, exec_state, event_data, data) {
case Debug.ScriptCompilationType.Eval:
eval_compilations++;
break;
- case Debug.ScriptCompilationType.JSON:
- json_compilations++;
- break;
}
}
@@ -74,13 +70,6 @@ function listener(event, exec_state, event_data, data) {
// For source with 'eval' there will be compile events with substrings
// as well as with with the exact source.
assertTrue(current_source.indexOf(event_data.script().source()) >= 0);
- } else if (current_source.indexOf('JSON.parse') == 0) {
- // For JSON the JSON source will be in parentheses.
- var s = event_data.script().source();
- if (s[0] == '(') {
- s = s.substring(1, s.length - 2);
- }
- assertTrue(current_source.indexOf(s) >= 0);
} else {
// For source without 'eval' there will be a compile events with the
// exact source.
@@ -113,7 +102,7 @@ source_count++; // Using eval causes additional compilation event.
compileSource('eval("eval(\'(function(){return a;})\')")');
source_count += 2; // Using eval causes additional compilation event.
compileSource('JSON.parse(\'{"a":1,"b":2}\')');
-source_count++; // Using JSON.parse causes additional compilation event.
+// Using JSON.parse does not causes additional compilation events.
compileSource('x=1; //@ sourceURL=myscript.js');
// Make sure that the debug event listener was invoked.
@@ -123,10 +112,9 @@ assertFalse(exception, "exception in listener")
assertEquals(before_compile_count, after_compile_count);
// Check the actual number of events (no compilation through the API as all
-// source compiled through eval except for one JSON.parse call).
+// source compiled through eval).
assertEquals(source_count, after_compile_count);
assertEquals(0, host_compilations);
-assertEquals(source_count - 1, eval_compilations);
-assertEquals(1, json_compilations);
+assertEquals(source_count, eval_compilations);
Debug.setListener(null);
diff --git a/test/mjsunit/mirror-script.js b/test/mjsunit/mirror-script.js
index 8631028e..71561701 100644
--- a/test/mjsunit/mirror-script.js
+++ b/test/mjsunit/mirror-script.js
@@ -83,12 +83,10 @@ function testScriptMirror(f, file_name, file_lines, type, compilation_type,
// Test the script mirror for different functions.
-testScriptMirror(function(){}, 'mirror-script.js', 100, 2, 0);
+testScriptMirror(function(){}, 'mirror-script.js', 98, 2, 0);
testScriptMirror(Math.sin, 'native math.js', -1, 0, 0);
testScriptMirror(eval('(function(){})'), null, 1, 2, 1, '(function(){})', 87);
testScriptMirror(eval('(function(){\n })'), null, 2, 2, 1, '(function(){\n })', 88);
-testScriptMirror(%CompileString('{"a":1,"b":2}', true), null, 1, 2, 2, '{"a":1,"b":2}');
-testScriptMirror(%CompileString('{"a":1,\n "b":2}', true), null, 2, 2, 2, '{"a":1,\n "b":2}');
// Test taking slices of source.
var mirror = debug.MakeMirror(eval('(function(){\n 1;\n})')).script();
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index 3c8cbdbf..820dca7c 100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -45,6 +45,10 @@ unicode-case-overoptimization: PASS, TIMEOUT if ($arch == arm)
# Skip long running test in debug and allow it to timeout in release mode.
regress/regress-524: (PASS || TIMEOUT), SKIP if $mode == debug
+# Stack manipulations in LiveEdit are buggy - see bug 915
+debug-liveedit-check-stack: SKIP
+debug-liveedit-patch-positions-replace: SKIP
+
[ $arch == arm ]
# Slow tests which times out in debug mode.
@@ -61,14 +65,9 @@ array-splice: PASS || TIMEOUT
# Skip long running test in debug mode on ARM.
string-indexof-2: PASS, SKIP if $mode == debug
-# Stack manipulations in LiveEdit is implemented for ia32 only.
-debug-liveedit-check-stack: SKIP
[ $arch == mips ]
-# Stack manipulations in LiveEdit is implemented for ia32 only.
-debug-liveedit-check-stack: SKIP
-
# Skip all tests on MIPS.
*: SKIP
diff --git a/test/mjsunit/object-literal-conversions.js b/test/mjsunit/object-literal-conversions.js
new file mode 100644
index 00000000..8540d930
--- /dev/null
+++ b/test/mjsunit/object-literal-conversions.js
@@ -0,0 +1,46 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test that the various conversions between property names are correctly
+// used when overwriting initializers.
+
+var test1 = { 13: 6, "13": 7 };
+var test2 = { 13: 7, "13.0": 6 };
+var test3 = { "13": 6, 13.0000000000000000: 7 };
+var test4 = { 13.213000: 6, "13.213": 7 };
+
+assertEquals(7, test1[13]);
+assertEquals(7, test2[13]);
+assertEquals(7, test3[13]);
+assertEquals(7, test4[13.213]);
+
+var test5 = { 13: function() {}, "13": 7 };
+var test6 = { 17.31: function() {}, "17.31": 7 };
+
+assertEquals(7, test5[13]);
+assertEquals(7, test6[17.31]);
+ \ No newline at end of file
diff --git a/test/mjsunit/object-literal-overwrite.js b/test/mjsunit/object-literal-overwrite.js
new file mode 100644
index 00000000..5c58a2dd
--- /dev/null
+++ b/test/mjsunit/object-literal-overwrite.js
@@ -0,0 +1,118 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Check that constants and computed properties are overwriting each other
+// correctly, i.e., the last initializer for any name is stored in the object.
+
+
+// Tests for the full code generator (if active).
+
+var foo1 = {
+ bar: 6,
+ bar: 7
+};
+
+var foo2 = {
+ bar: function(a){},
+ bar: 7
+};
+
+var foo3 = {
+ bar: function(a){},
+ bar: function(b){},
+ bar: 7
+};
+
+var foo4 = {
+ bar: function(b){},
+ bar: 7,
+ bar: function(){return 7},
+};
+
+var foo5 = {
+ 13: function(a){},
+ 13: 7
+}
+
+var foo6 = {
+ 14.31: function(a){},
+ 14.31: 7
+}
+
+var foo7 = {
+ 15: 6,
+ 15: 7
+}
+
+assertEquals(7, foo1.bar);
+assertEquals(7, foo2.bar);
+assertEquals(7, foo3.bar);
+assertEquals(7, foo4.bar());
+assertEquals(7, foo5[13]);
+assertEquals(7, foo6[14.31]);
+assertEquals(7, foo7[15]);
+
+// Test for the classic code generator.
+
+function fun(x) {
+ var inner = { j: function(x) { return x; }, j: 7 };
+ return inner.j;
+}
+
+assertEquals(7, fun(7) );
+
+// Check that the initializers of computed properties are executed, even if
+// no store instructions are generated for the literals.
+
+var glob1 = 0;
+
+var bar1 = { x: glob1++, x: glob1++, x: glob1++, x: 7};
+
+assertEquals(3, glob1);
+
+
+var glob2 = 0;
+
+function fun2() {
+ var r = { y: glob2++, y: glob2++, y: glob2++, y: 7};
+ return r.y;
+}
+
+var y = fun2();
+assertEquals(7, y);
+assertEquals(3, glob2);
+
+var glob3 = 0;
+
+function fun3() {
+ var r = { 113: glob3++, 113: glob3++, 113: glob3++, 113: 7};
+ return r[113];
+}
+
+var y = fun3();
+assertEquals(7, y);
+assertEquals(3, glob3); \ No newline at end of file
diff --git a/test/mjsunit/regress/regress-conditional-position.js b/test/mjsunit/regress/regress-conditional-position.js
new file mode 100644
index 00000000..cd8f7bd7
--- /dev/null
+++ b/test/mjsunit/regress/regress-conditional-position.js
@@ -0,0 +1,95 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --always-full-compiler
+
+var functionToCatch;
+var lineNumber;
+
+function catchLineNumber () {
+ var x = {};
+
+ Error.prepareStackTrace = function (error, stackTrace) {
+ stackTrace.some(function (frame) {
+ if (frame.getFunction() == functionToCatch) {
+ lineNumber = frame.getLineNumber();
+ return true;
+ }
+ return false;
+ });
+ return lineNumber;
+ };
+
+ Error.captureStackTrace(x);
+ return x.stack;
+}
+
+function log() {
+ catchLineNumber();
+}
+
+function foo() {}
+
+function test1() {
+ log(foo() == foo()
+ ? 'a'
+ : 'b');
+}
+
+function test2() {
+ var o = { foo: function () {}}
+ log(o.foo() == o.foo()
+ ? 'a'
+ : 'b');
+}
+
+function test3() {
+ var o = { log: log, foo: function() { } };
+ o.log(o.foo() == o.foo()
+ ? 'a'
+ : 'b');
+
+}
+
+function test(f, expectedLineNumber) {
+ functionToCatch = f;
+ f();
+
+ assertEquals(expectedLineNumber, lineNumber);
+}
+
+test(test1, 58);
+test(test2, 65);
+test(test3, 72);
+
+eval(test1.toString() + "//@ sourceUrl=foo");
+eval(test2.toString() + "//@ sourceUrl=foo");
+eval(test3.toString() + "//@ sourceUrl=foo");
+
+test(test1, 2);
+test(test2, 3);
+test(test3, 3);
diff --git a/test/mjsunit/string-externalize.js b/test/mjsunit/string-externalize.js
index 5b1f9170..da897869 100644
--- a/test/mjsunit/string-externalize.js
+++ b/test/mjsunit/string-externalize.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --expose-externalize-string
+// Flags: --expose-externalize-string --expose-gc
var size = 1024;
@@ -93,3 +93,7 @@ function test() {
for (var i = 0; i < 10; i++) {
test();
}
+
+// Clean up string to make Valgrind happy.
+gc();
+gc();
diff --git a/test/mjsunit/string-replace-with-empty.js b/test/mjsunit/string-replace-with-empty.js
index 0e1e70a1..aa97f27a 100644
--- a/test/mjsunit/string-replace-with-empty.js
+++ b/test/mjsunit/string-replace-with-empty.js
@@ -25,33 +25,45 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --expose-externalize-string
+// Flags: --expose-externalize-string --expose-gc
-assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, ""));
-assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, ""));
+function test() {
+ assertEquals("0123", "aa0bb1cc2dd3".replace(/[a-z]/g, ""));
+ assertEquals("0123", "\u1234a0bb1cc2dd3".replace(/[\u1234a-z]/g, ""));
-var expected = "0123";
-var cons = "a0b1c2d3";
-for (var i = 0; i < 5; i++) {
- expected += expected;
- cons += cons;
-}
-assertEquals(expected, cons.replace(/[a-z]/g, ""));
-cons = "\u12340b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
-}
-assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
+ var expected = "0123";
+ var cons = "a0b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ expected += expected;
+ cons += cons;
+ }
+ assertEquals(expected, cons.replace(/[a-z]/g, ""));
+ cons = "\u12340b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
-cons = "a0b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
-}
-externalizeString(cons, true/* force two-byte */);
-assertEquals(expected, cons.replace(/[a-z]/g, ""));
-cons = "\u12340b1c2d3";
-for (var i = 0; i < 5; i++) {
- cons += cons;
+ cons = "a0b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ externalizeString(cons, true/* force two-byte */);
+ assertEquals(expected, cons.replace(/[a-z]/g, ""));
+ cons = "\u12340b1c2d3";
+ for (var i = 0; i < 5; i++) {
+ cons += cons;
+ }
+ externalizeString(cons);
+ assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
}
-externalizeString(cons);
-assertEquals(expected, cons.replace(/[\u1234a-z]/g, ""));
+
+test();
+
+// Clear the regexp cache to allow the GC to work.
+"foo".replace(/foo/g, "");
+
+// GC in order to free up things on the C side so we don't get
+// a memory leak. This makes valgrind happy.
+gc();
+gc();
diff --git a/test/mjsunit/string-split.js b/test/mjsunit/string-split.js
index 59d3ad3e..c741f6a3 100644
--- a/test/mjsunit/string-split.js
+++ b/test/mjsunit/string-split.js
@@ -27,76 +27,45 @@
expected = ["A", undefined, "B", "bold", "/", "B", "and", undefined, "CODE", "coded", "/", "CODE", ""];
result = "A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/);
-assertArrayEquals(expected, result, 1);
+assertArrayEquals(expected, result);
-expected = ["a", "b"];
-result = "ab".split(/a*?/);
-assertArrayEquals(expected, result, 2);
-expected = ["", "b"];
-result = "ab".split(/a*/);
-assertArrayEquals(expected, result, 3);
+assertArrayEquals(["a", "b"], "ab".split(/a*?/));
-expected = ["a"];
-result = "ab".split(/a*?/, 1);
-assertArrayEquals(expected, result, 4);
+assertArrayEquals(["", "b"], "ab".split(/a*/));
-expected = [""];
-result = "ab".split(/a*/, 1);
-assertArrayEquals(expected, result, 5);
+assertArrayEquals(["a"], "ab".split(/a*?/, 1));
-expected = ["as","fas","fas","f"];
-result = "asdfasdfasdf".split("d");
-assertArrayEquals(expected, result, 6);
+assertArrayEquals([""], "ab".split(/a*/, 1));
-expected = ["as","fas","fas","f"];
-result = "asdfasdfasdf".split("d", -1);
-assertArrayEquals(expected, result, 7);
+assertArrayEquals(["as","fas","fas","f"], "asdfasdfasdf".split("d"));
-expected = ["as", "fas"];
-result = "asdfasdfasdf".split("d", 2);
-assertArrayEquals(expected, result, 8);
+assertArrayEquals(["as","fas","fas","f"], "asdfasdfasdf".split("d", -1));
-expected = [];
-result = "asdfasdfasdf".split("d", 0);
-assertArrayEquals(expected, result, 9);
+assertArrayEquals(["as", "fas"], "asdfasdfasdf".split("d", 2));
-expected = ["as","fas","fas",""];
-result = "asdfasdfasd".split("d");
-assertArrayEquals(expected, result, 10);
+assertArrayEquals([], "asdfasdfasdf".split("d", 0));
-expected = [];
-result = "".split("");
-assertArrayEquals(expected, result, 11);
+assertArrayEquals(["as","fas","fas",""], "asdfasdfasd".split("d"));
-expected = [""]
-result = "".split("a");
-assertArrayEquals(expected, result, 12);
+assertArrayEquals([], "".split(""));
-expected = ["a","b"]
-result = "axxb".split(/x*/);
-assertArrayEquals(expected, result, 13);
+assertArrayEquals([""], "".split("a"));
-expected = ["a","b"]
-result = "axxb".split(/x+/);
-assertArrayEquals(expected, result, 14);
+assertArrayEquals(["a","b"], "axxb".split(/x*/));
-expected = ["a","","b"]
-result = "axxb".split(/x/);
-assertArrayEquals(expected, result, 15);
+assertArrayEquals(["a","b"], "axxb".split(/x+/));
+
+assertArrayEquals(["a","","b"], "axxb".split(/x/));
// This was http://b/issue?id=1151354
-expected = ["div", "#id", ".class"]
-result = "div#id.class".split(/(?=[#.])/);
-assertArrayEquals(expected, result, 16);
+assertArrayEquals(["div", "#id", ".class"], "div#id.class".split(/(?=[#.])/));
+
-expected = ["div", "#i", "d", ".class"]
-result = "div#id.class".split(/(?=[d#.])/);
-assertArrayEquals(expected, result, 17);
+assertArrayEquals(["div", "#i", "d", ".class"], "div#id.class".split(/(?=[d#.])/));
+
+assertArrayEquals(["a", "b", "c"], "abc".split(/(?=.)/));
-expected = ["a", "b", "c"]
-result = "abc".split(/(?=.)/);
-assertArrayEquals(expected, result, 18);
/* "ab".split(/((?=.))/)
*
@@ -108,19 +77,23 @@ assertArrayEquals(expected, result, 18);
*
* Opera seems to have this right. The others make no sense.
*/
-expected = ["a", "", "b"]
-result = "ab".split(/((?=.))/);
-assertArrayEquals(expected, result, 19);
+assertArrayEquals(["a", "", "b"], "ab".split(/((?=.))/));
/* "ab".split(/(?=)/)
*
* KJS: a,b
* SM: ab
* IE: a,b
- * Opera: a,b
+ * Opera: a,bb
* V8: a,b
*/
-expected = ["a", "b"]
-result = "ab".split(/(?=)/);
-assertArrayEquals(expected, result, 20);
+assertArrayEquals(["a", "b"], "ab".split(/(?=)/));
+
+// For issue http://code.google.com/p/v8/issues/detail?id=924
+// Splitting the empty string is a special case.
+assertEquals([""], ''.split());
+assertEquals([""], ''.split(/./));
+assertEquals([], ''.split(/.?/));
+assertEquals([], ''.split(/.??/));
+assertEquals([], ''.split(/()()/));