Skip to content

Commit

Permalink
Added unit tests of Symbol.species for various built-ins
Browse files Browse the repository at this point in the history
`Map`, `Array`, `RegExp`, and `Promise`
  • Loading branch information
andreabergia authored and rbri committed Mar 4, 2024
1 parent e617cf0 commit bacddc4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions testsrc/jstests/es6/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ var a = Array.from(Array(2));
assertTrue(0 in a);
assertEquals(a.map(_ => 'a'), ['a', 'a']);

(function TestSymbolSpecies() {
var symbolSpeciesValue = Array[Symbol.species];
assertEquals(Array, symbolSpeciesValue);
})();

"success";
5 changes: 5 additions & 0 deletions testsrc/jstests/es6/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,9 @@ function logElement(value, key, m) {
}
})();

(function TestSymbolSpecies() {
var symbolSpeciesValue = Map[Symbol.species];
assertEquals(Map, symbolSpeciesValue);
})();

"success";
7 changes: 6 additions & 1 deletion testsrc/jstests/es6/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,11 @@ function assertAsyncDone(iteration) {
assertEquals(1, callCount);
})();

assertAsyncDone()
assertAsyncDone();

(function TestSymbolSpecies() {
var symbolSpeciesValue = Promise[Symbol.species];
assertEquals(Promise, symbolSpeciesValue);
})();

'success';
8 changes: 8 additions & 0 deletions testsrc/jstests/es6/regexp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load('testsrc/assert.js');

(function TestSymbolSpecies() {
var symbolSpeciesValue = RegExp[Symbol.species];
assertEquals(RegExp, symbolSpeciesValue);
})();

'success';
14 changes: 14 additions & 0 deletions testsrc/org/mozilla/javascript/tests/es6/RegExpBasicTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.javascript.tests.es6;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.drivers.LanguageVersion;
import org.mozilla.javascript.drivers.RhinoTest;
import org.mozilla.javascript.drivers.ScriptTestsBase;

@RhinoTest("testsrc/jstests/es6/regexp.js")
@LanguageVersion(Context.VERSION_ES6)
public class RegExpBasicTest extends ScriptTestsBase {}

0 comments on commit bacddc4

Please sign in to comment.