Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up JavaScriptCore/builtins
https://bugs.webkit.org/show_bug.cgi?id=143177

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-28
Reviewed by Ryosuke Niwa.

* builtins/ArrayConstructor.js:
(from):
- We can compare to undefined instead of using a typeof undefined check.
- Converge on double quoted strings everywhere.

* builtins/ArrayIterator.prototype.js:
(next):
* builtins/StringIterator.prototype.js:
(next):
- Use shorthand object construction to avoid duplication.
- Improve grammar in error messages.

* tests/stress/array-iterators-next-with-call.js:
* tests/stress/string-iterators.js:
- Update for new error message strings.

Canonical link: https://commits.webkit.org/161218@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Mar 29, 2015
1 parent 34c51c7 commit 6170817
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
23 changes: 23 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,26 @@
2015-03-28 Joseph Pecoraro <pecoraro@apple.com>

Clean up JavaScriptCore/builtins
https://bugs.webkit.org/show_bug.cgi?id=143177

Reviewed by Ryosuke Niwa.

* builtins/ArrayConstructor.js:
(from):
- We can compare to undefined instead of using a typeof undefined check.
- Converge on double quoted strings everywhere.

* builtins/ArrayIterator.prototype.js:
(next):
* builtins/StringIterator.prototype.js:
(next):
- Use shorthand object construction to avoid duplication.
- Improve grammar in error messages.

* tests/stress/array-iterators-next-with-call.js:
* tests/stress/string-iterators.js:
- Update for new error message strings.

2015-03-28 Saam Barati <saambarati1@gmail.com>

Web Inspector: ES6: Better support for Symbol types in Type Profiler
Expand Down
9 changes: 4 additions & 5 deletions Source/JavaScriptCore/builtins/ArrayConstructor.js
Expand Up @@ -24,11 +24,10 @@
*/

function from(arrayLike /*, mapFn, thisArg */) {

"use strict";

if (arrayLike == null)
throw new @TypeError("Array.from requires an array-like object - not null or undefined");
throw new @TypeError("Array.from requires an array-like object - not null or undefined");

var thisObj = this;

Expand All @@ -37,8 +36,8 @@ function from(arrayLike /*, mapFn, thisArg */) {

var thisArg;

if (typeof mapFn !== "undefined") {
if (typeof mapFn !== 'function')
if (mapFn !== undefined) {
if (typeof mapFn !== "function")
throw new @TypeError("Array.from requires that the second argument, when provided, be a function");

if (arguments.length > 2)
Expand All @@ -58,7 +57,7 @@ function from(arrayLike /*, mapFn, thisArg */) {
// originally Math.min(Math.max(length, 0), maxSafeInteger));
var itemsLength = lengthValue > 0 ? (lengthValue < maxSafeInteger ? lengthValue : maxSafeInteger) : 0;

var result = (typeof thisObj === 'function') ? @Object(new thisObj(itemsLength)) : new @Array(itemsLength);
var result = (typeof thisObj === "function") ? @Object(new thisObj(itemsLength)) : new @Array(itemsLength);

var k = 0;
while (k < itemsLength) {
Expand Down
7 changes: 2 additions & 5 deletions Source/JavaScriptCore/builtins/ArrayIterator.prototype.js
Expand Up @@ -31,7 +31,7 @@ function next() {

var itemKind = this.@arrayIterationKind;
if (itemKind === undefined)
throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| be Array Iterator Instance");
throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance");

var done = true;
var value = undefined;
Expand All @@ -55,8 +55,5 @@ function next() {
}
}

return {
done: done,
value: value
};
return {done, value};
}
7 changes: 2 additions & 5 deletions Source/JavaScriptCore/builtins/StringIterator.prototype.js
Expand Up @@ -31,7 +31,7 @@ function next() {

var position = this.@stringIteratorNextIndex;
if (position === undefined)
throw new @TypeError("%StringIteratorPrototype%.next requires that |this| be String Iterator Instance");
throw new @TypeError("%StringIteratorPrototype%.next requires that |this| be a String Iterator instance");

var done = true;
var value = undefined;
Expand Down Expand Up @@ -59,8 +59,5 @@ function next() {
}
}

return {
done: done,
value: value
};
return {done, value};
}
Expand Up @@ -83,7 +83,7 @@ for (var primitive of primitives) {
}
if (!didThrow)
throw "Error: no error thrown";
var expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| be Array Iterator Instance';
var expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance';
if (primitive == null)
expectedMessage = 'TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null or undefined';
if (String(didThrow) !== expectedMessage)
Expand All @@ -110,6 +110,6 @@ for (var object of nonRelatedObjects) {
}
if (!didThrow)
throw "Error: no error thrown";
if (String(didThrow) !== 'TypeError: %ArrayIteratorPrototype%.next requires that |this| be Array Iterator Instance')
if (String(didThrow) !== 'TypeError: %ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance')
throw "Error: bad error thrown: " + didThrow;
}
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/tests/stress/string-iterators.js
Expand Up @@ -180,7 +180,7 @@ for (var primitive of primitives) {
}
if (!didThrow)
throw "Error: no error thrown";
var message = 'TypeError: %StringIteratorPrototype%.next requires that |this| be String Iterator Instance';
var message = 'TypeError: %StringIteratorPrototype%.next requires that |this| be a String Iterator instance';
if (primitive == null)
message = 'TypeError: %StringIteratorPrototype%.next requires that |this| be not null or undefined'
if (String(didThrow) !== message)
Expand All @@ -207,6 +207,6 @@ for (var object of nonRelatedObjects) {
}
if (!didThrow)
throw "Error: no error thrown";
if (String(didThrow) !== 'TypeError: %StringIteratorPrototype%.next requires that |this| be String Iterator Instance')
if (String(didThrow) !== 'TypeError: %StringIteratorPrototype%.next requires that |this| be a String Iterator instance')
throw "Error: bad error thrown: " + didThrow;
}

0 comments on commit 6170817

Please sign in to comment.