Skip to content

Commit 409c930

Browse files
committed
[JSC] Remove remaining hard coded test loop count for JSTests/stress
https://bugs.webkit.org/show_bug.cgi?id=290255 Reviewed by Yusuke Suzuki. https://commits.webkit.org/289981@main introduced `testLoopCount` for JS tests. But loop counts written as `runs = value` are remaining. This patch fixes it. * JSTests/stress/iterator-open-throw-for-non-objects.js: * JSTests/stress/number-prototype-to-string-dfg-bad-this-value-radix-10.js: * JSTests/stress/number-prototype-to-string-dfg-bad-this-value-radix-absent.js: * JSTests/stress/putDirectWithReify-JSFinalObject.js: * JSTests/stress/regexp-exec-consistent-error-message.js: (test): * JSTests/stress/regexp-split-side-effects-via-hasIndices-and-dotAll.js: * JSTests/stress/string-prototype-at.js: (test): Canonical link: https://commits.webkit.org/292553@main
1 parent c5b7d05 commit 409c930

7 files changed

Lines changed: 41 additions & 53 deletions

JSTests/stress/iterator-open-throw-for-non-objects.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ function shouldBe(actual, expected) {
33
throw new Error(`expected ${expected} but got ${actual}`);
44
}
55

6-
const runs = 1e5;
7-
86
let count = 0;
9-
for (let i = 0; i < runs; i++) {
7+
for (let i = 0; i < testLoopCount; i++) {
108
try {
119
const arr = [101, 101];
1210
arr[Symbol.iterator] = function () { return 3; };
@@ -15,10 +13,10 @@ for (let i = 0; i < runs; i++) {
1513
count++;
1614
}
1715
}
18-
shouldBe(count, runs);
16+
shouldBe(count, testLoopCount);
1917
count = 0;
2018

21-
for (let i = 0; i < runs; i++) {
19+
for (let i = 0; i < testLoopCount; i++) {
2220
try {
2321
const arr = [101, 101];
2422
arr[Symbol.iterator] = function () { return "foo"; };
@@ -27,10 +25,10 @@ for (let i = 0; i < runs; i++) {
2725
count++;
2826
}
2927
}
30-
shouldBe(count, runs);
28+
shouldBe(count, testLoopCount);
3129
count = 0;
3230

33-
for (let i = 0; i < runs; i++) {
31+
for (let i = 0; i < testLoopCount; i++) {
3432
try {
3533
const arr = [101, 101];
3634
arr[Symbol.iterator] = function () { return true; };
@@ -39,10 +37,10 @@ for (let i = 0; i < runs; i++) {
3937
count++;
4038
}
4139
}
42-
shouldBe(count, runs);
40+
shouldBe(count, testLoopCount);
4341
count = 0;
4442

45-
for (let i = 0; i < runs; i++) {
43+
for (let i = 0; i < testLoopCount; i++) {
4644
try {
4745
const arr = [101, 101];
4846
arr[Symbol.iterator] = function () { return null; };
@@ -51,10 +49,10 @@ for (let i = 0; i < runs; i++) {
5149
count++;
5250
}
5351
}
54-
shouldBe(count, runs);
52+
shouldBe(count, testLoopCount);
5553
count = 0;
5654

57-
for (let i = 0; i < runs; i++) {
55+
for (let i = 0; i < testLoopCount; i++) {
5856
try {
5957
const arr = [101, 101];
6058
arr[Symbol.iterator] = function () { return undefined; };
@@ -63,10 +61,10 @@ for (let i = 0; i < runs; i++) {
6361
count++;
6462
}
6563
}
66-
shouldBe(count, runs);
64+
shouldBe(count, testLoopCount);
6765
count = 0;
6866

69-
for (let i = 0; i < runs; i++) {
67+
for (let i = 0; i < testLoopCount; i++) {
7068
try {
7169
const arr = [101, 101];
7270
arr[Symbol.iterator] = function () { return Symbol("foo"); };
@@ -75,10 +73,10 @@ for (let i = 0; i < runs; i++) {
7573
count++;
7674
}
7775
}
78-
shouldBe(count, runs);
76+
shouldBe(count, testLoopCount);
7977
count = 0;
8078

81-
for (let i = 0; i < runs; i++) {
79+
for (let i = 0; i < testLoopCount; i++) {
8280
try {
8381
const arr = [101, 101];
8482
arr[Symbol.iterator] = function () { return 3n; };
@@ -87,5 +85,5 @@ for (let i = 0; i < runs; i++) {
8785
count++;
8886
}
8987
}
90-
shouldBe(count, runs);
88+
shouldBe(count, testLoopCount);
9189
count = 0;

JSTests/stress/number-prototype-to-string-dfg-bad-this-value-radix-10.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ function numberToString(thisValue) {
1010
}
1111

1212
(function() {
13-
const runs = 1e6;
14-
15-
for (let i = 0; i < runs; i++) {
13+
for (let i = 0; i < testLoopCount; i++) {
1614
numberToString({});
1715
numberToString(i);
1816
}
1917

20-
if (successCount !== runs)
18+
if (successCount !== testLoopCount)
2119
throw new Error(`Bad value: ${successCount}!`);
2220

23-
if (errorCount !== runs)
21+
if (errorCount !== testLoopCount)
2422
throw new Error(`Bad value: ${errorCount}!`);
2523
})();

JSTests/stress/number-prototype-to-string-dfg-bad-this-value-radix-absent.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ function numberToString(thisValue) {
1010
}
1111

1212
(function() {
13-
const runs = 1e6;
14-
15-
for (let i = 0; i < runs; i++) {
13+
for (let i = 0; i < testLoopCount; i++) {
1614
numberToString({});
1715
numberToString(i);
1816
}
1917

20-
if (successCount !== runs)
18+
if (successCount !== testLoopCount)
2119
throw new Error(`Bad value: ${successCount}!`);
2220

23-
if (errorCount !== runs)
21+
if (errorCount !== testLoopCount)
2422
throw new Error(`Bad value: ${errorCount}!`);
2523
})();

JSTests/stress/putDirectWithReify-JSFinalObject.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"use strict";
22

3-
const runs = 1e5;
4-
53
function shouldBe(actual, expected) {
64
if (actual !== expected)
75
throw new Error(`Bad value: ${actual}!`);
@@ -31,7 +29,7 @@ function shouldThrow(func, errorMessage) {
3129
foo = 1;
3230
}
3331

34-
for (var i = 0; i < runs; i++) {
32+
for (var i = 0; i < testLoopCount; i++) {
3533
shouldThrow(() => { new TestFinalObjectDontDelete(); }, "TypeError: Attempting to change configurable attribute of unconfigurable property.");
3634
}
3735

@@ -47,7 +45,7 @@ function shouldThrow(func, errorMessage) {
4745
foo = 42;
4846
}
4947

50-
for (var i = 0; i < runs; i++) {
48+
for (var i = 0; i < testLoopCount; i++) {
5149
var object = new TestFinalObjectReadOnly();
5250
shouldBe(object.foo, 42);
5351

@@ -70,7 +68,7 @@ function shouldThrow(func, errorMessage) {
7068
foo = 42;
7169
}
7270

73-
for (var i = 0; i < runs; i++) {
71+
for (var i = 0; i < testLoopCount; i++) {
7472
shouldThrow(() => { new TestFinalObjectNonExtendable(); }, "TypeError: Attempting to define property on object that is not extensible.");
7573
}
7674
})();
@@ -86,7 +84,7 @@ function shouldThrow(func, errorMessage) {
8684
dontEnum = 42;
8785
}
8886

89-
for (var i = 0; i < runs; i++) {
87+
for (var i = 0; i < testLoopCount; i++) {
9088
var object = new TestNonReifiedStaticDontEnum();
9189
shouldBe(object.dontEnum, 42);
9290

@@ -101,7 +99,7 @@ function shouldThrow(func, errorMessage) {
10199
dontDelete = "foo";
102100
}
103101

104-
for (var i = 0; i < runs; i++) {
102+
for (var i = 0; i < testLoopCount; i++) {
105103
shouldThrow(() => { new TestNonReifiedStaticDontDelete(); }, "TypeError: Attempting to change configurable attribute of unconfigurable property.");
106104
}
107105
})();

JSTests/stress/regexp-exec-consistent-error-message.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ function shouldBe(a, b) {
33
throw new Error(`expected ${b} but got ${a}`);
44
}
55

6-
const runs = 1e5;
76
const regExpPrototype = RegExp.prototype;
87

98
function test(propertyName) {
109
let count = 0;
1110
let message = null;
12-
for (let i = 0; i < runs; i++) {
11+
for (let i = 0; i < testLoopCount; i++) {
1312
try {
1413
regExpPrototype[propertyName]();
1514
} catch (error) {
@@ -19,7 +18,7 @@ function test(propertyName) {
1918
count++;
2019
}
2120
}
22-
shouldBe(count, runs);
21+
shouldBe(count, testLoopCount);
2322
}
2423

2524
noInline(test);

JSTests/stress/regexp-split-side-effects-via-hasIndices-and-dotAll.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ Object.defineProperty(re, "dotAll", {
2020
}
2121
});
2222

23-
const runs = 1e6;
24-
25-
for (let i = 0; i < runs; i++) {
23+
for (let i = 0; i < testLoopCount; i++) {
2624
re[Symbol.split]("abc");
2725
}
2826

29-
sameValue(dotAllCount, runs);
30-
sameValue(hasIndicesCount, runs);
27+
sameValue(dotAllCount, testLoopCount);
28+
sameValue(hasIndicesCount, testLoopCount);

JSTests/stress/string-prototype-at.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ function stringAt(string, index) {
88
}
99
noInline(stringAt);
1010

11-
const runs = 1e6;
1211
function test(str, index, expected) {
1312
let count = 0;
14-
for (let i = 0; i < runs; i++) {
13+
for (let i = 0; i < testLoopCount; i++) {
1514
if (stringAt(str, index) === expected)
1615
count++;
1716
}
@@ -22,14 +21,14 @@ noInline(test);
2221
const string8 = "hello, world";
2322
const string16 = "こんにちは、世界";
2423

25-
shouldBe(test(string16, 0, "こ"), runs);
26-
shouldBe(test(string16, 2, "に"), runs);
27-
shouldBe(test(string16, 20, undefined), runs);
28-
shouldBe(test(string16, -2, "世"), runs);
29-
shouldBe(test(string16, -40, undefined), runs);
24+
shouldBe(test(string16, 0, "こ"), testLoopCount);
25+
shouldBe(test(string16, 2, "に"), testLoopCount);
26+
shouldBe(test(string16, 20, undefined), testLoopCount);
27+
shouldBe(test(string16, -2, "世"), testLoopCount);
28+
shouldBe(test(string16, -40, undefined), testLoopCount);
3029

31-
shouldBe(test(string8, 0, "h"), runs);
32-
shouldBe(test(string8, 2, "l"), runs);
33-
shouldBe(test(string8, 20, undefined), runs);
34-
shouldBe(test(string8, -2, "l"), runs);
35-
shouldBe(test(string8, -40, undefined), runs);
30+
shouldBe(test(string8, 0, "h"), testLoopCount);
31+
shouldBe(test(string8, 2, "l"), testLoopCount);
32+
shouldBe(test(string8, 20, undefined), testLoopCount);
33+
shouldBe(test(string8, -2, "l"), testLoopCount);
34+
shouldBe(test(string8, -40, undefined), testLoopCount);

0 commit comments

Comments
 (0)