summaryrefslogtreecommitdiff
path: root/deps/v8/test/js-perf-test/StringIterators/string-iterator.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/js-perf-test/StringIterators/string-iterator.js')
-rw-r--r--deps/v8/test/js-perf-test/StringIterators/string-iterator.js55
1 files changed, 12 insertions, 43 deletions
diff --git a/deps/v8/test/js-perf-test/StringIterators/string-iterator.js b/deps/v8/test/js-perf-test/StringIterators/string-iterator.js
index c55925415b..8a7e323b42 100644
--- a/deps/v8/test/js-perf-test/StringIterators/string-iterator.js
+++ b/deps/v8/test/js-perf-test/StringIterators/string-iterator.js
@@ -2,37 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-function assert(expression, message) {
- if (typeof expression === "string" && message === void 0) {
- message = expression;
- expression = eval(expression);
- }
-
- if (!expression) {
- var lines = ["Benchmark Error"];
- if (message !== void 0) {
- lines = ["Benchmark Error:", String(message)];
- }
- throw new Error(lines.join("\n"));
- }
- return true;
-}
-
-assert.same = function(expected, actual, message) {
- var isSame =
- expected === actual || typeof expected !== expected && actual !== actual;
- if (!isSame) {
- var details = `Expected: ${String(expected)}\n` +
- `But found: ${String(actual)}`;
- var lines = ["Benchmark Error:", details];
- if (message !== void 0) {
- lines = ["Benchmark Error:", details, "", String(message)];
- }
- throw new Error(lines.join("\n"));
- }
- return true;
-}
-
new BenchmarkSuite('Spread_OneByteShort', [1000], [
new Benchmark('test', false, false, 0,
Spread_OneByteShort, Spread_OneByteShortSetup,
@@ -52,8 +21,8 @@ function Spread_OneByteShort() {
function Spread_OneByteShortTearDown() {
var expected = "A|l|p|h|a|b|e|t|-|S|o|u|p";
- return assert("Array.isArray(result)")
- && assert.same(expected, result.join("|"));
+ return assert(Array.isArray(result))
+ && assertEquals(expected, result.join("|"));
}
// ----------------------------------------------------------------------------
@@ -75,8 +44,8 @@ function Spread_TwoByteShort() {
function Spread_TwoByteShortTearDown() {
var expected = "\u5FCD|\u8005|\u306E|\u653B|\u6483";
- return assert("Array.isArray(result)")
- && assert.same(expected, result.join("|"));
+ return assert(Array.isArray(result))
+ && assertEquals(expected, result.join("|"));
}
// ----------------------------------------------------------------------------
@@ -100,8 +69,8 @@ function Spread_WithSurrogatePairsShort() {
function Spread_WithSurrogatePairsShortTearDown() {
var expected =
"\uD83C\uDF1F|\u5FCD|\u8005|\u306E|\u653B|\u6483|\uD83C\uDF1F";
- return assert("Array.isArray(result)")
- && assert.same(expected, result.join("|"));
+ return assert(Array.isArray(result))
+ && assertEquals(expected, result.join("|"));
}
// ----------------------------------------------------------------------------
@@ -123,7 +92,7 @@ function ForOf_OneByteShort() {
}
function ForOf_OneByteShortTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}
// ----------------------------------------------------------------------------
@@ -145,7 +114,7 @@ function ForOf_TwoByteShort() {
}
function ForOf_TwoByteShortTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}
// ----------------------------------------------------------------------------
@@ -168,7 +137,7 @@ function ForOf_WithSurrogatePairsShort() {
}
function ForOf_WithSurrogatePairsShortTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}
// ----------------------------------------------------------------------------
@@ -190,7 +159,7 @@ function ForOf_OneByteLong() {
}
function ForOf_OneByteLongTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}
// ----------------------------------------------------------------------------
@@ -212,7 +181,7 @@ function ForOf_TwoByteLong() {
}
function ForOf_TwoByteLongTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}
// ----------------------------------------------------------------------------
@@ -235,5 +204,5 @@ function ForOf_WithSurrogatePairsLong() {
}
function ForOf_WithSurrogatePairsLongTearDown() {
- return assert.same(string, result);
+ return assertEquals(string, result);
}