forked from compat-table/compat-table
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract runner_support.createIterableHelper to test-utils.testHelpers
As the createIterableHelper export needs to be accessible on old environments that do not support newer EcmaScript syntax fix runner_support used combination of console.log and print Where 'print' is something native to Rhino and console.log (not being part of the EcmaScript spec) not available on all environments either Now the `logCommand` to use can be passed into runner_support.runTests via the options parameter
- Loading branch information
Showing
5 changed files
with
105 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// this file must only contain js code written in ES3 as it's used in tests | ||
|
||
exports.createIterableHelper = | ||
'function __createIterableObject(arr, methods) {\n' + | ||
' methods = methods || {};\n' + | ||
' if (typeof Symbol !== "function" || !Symbol.iterator)\n' + | ||
' return {};\n' + | ||
' arr.length++;\n' + | ||
' var iterator = {\n' + | ||
' next: function() {\n' + | ||
' return { value: arr.shift(), done: arr.length <= 0 };\n' + | ||
' },\n' + | ||
' "return": methods["return"],\n' + | ||
' "throw": methods["throw"]\n' + | ||
' };\n' + | ||
' var iterable = {};\n' + | ||
' iterable[Symbol.iterator] = function(){ return iterator; };\n' + | ||
' return iterable;\n' + | ||
'}\n' + | ||
'if (typeof global !== "undefined") {\n' + | ||
' global.__createIterableObject = __createIterableObject;\n' + | ||
'}\n'; |