-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example: rewrite import attributes tests
- Loading branch information
1 parent
ad9f91c
commit 31c6b7d
Showing
38 changed files
with
529 additions
and
11 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
test/language/import/import-attributes/json-extensibility-array.multi.md
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,31 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Creates extensible arrays | ||
flags: [module] | ||
includes: [propertyHelper.js] | ||
features: [import-attributes, json-modules] | ||
---*/ | ||
|
||
import value from './json-value-array_FIXTURE.json' with { type: 'json' }; | ||
|
||
value.test262property = 'test262 value'; | ||
|
||
verifyProperty(value, 'test262property', { | ||
value: 'test262 value', | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
``` | ||
|
||
## json-value-array_FIXTURE.json | ||
|
||
```json | ||
[] | ||
``` |
1 change: 1 addition & 0 deletions
1
...mport/import-attributes/json-extensibility-array__generated/json-value-array_FIXTURE.json
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 @@ | ||
[] |
4 changes: 4 additions & 0 deletions
4
...rt-attributes/json-extensibility-array.js → ...on-extensibility-array__generated/main.js
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
31 changes: 31 additions & 0 deletions
31
test/language/import/import-attributes/json-extensibility-object.multi.md
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,31 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Creates extensible objects | ||
flags: [module] | ||
includes: [propertyHelper.js] | ||
features: [import-attributes, json-modules] | ||
---*/ | ||
|
||
import value from './json-value-object_FIXTURE.json' with { type: 'json' }; | ||
|
||
value.test262property = 'test262 value'; | ||
|
||
verifyProperty(value, 'test262property', { | ||
value: 'test262 value', | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
``` | ||
|
||
## json-value-object_FIXTURE.json | ||
|
||
```json | ||
{} | ||
``` |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...t-attributes/json-extensibility-object.js → ...n-extensibility-object__generated/main.js
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
40 changes: 40 additions & 0 deletions
40
test/language/import/import-attributes/json-idempotency.multi.md
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,40 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: The same object representation is returned to all import sites | ||
flags: [module, async] | ||
features: [import-attributes, json-modules, globalThis, dynamic-import] | ||
---*/ | ||
|
||
import viaStaticImport1 from './json-idempotency_FIXTURE.json' with { type: 'json' }; | ||
import {default as viaStaticImport2} from './json-idempotency_FIXTURE.json' with { type: 'json' }; | ||
import './json-idempotency-indirect_FIXTURE.js'; | ||
|
||
assert.sameValue(viaStaticImport1, viaStaticImport2); | ||
assert.sameValue(globalThis.viaSecondModule, viaStaticImport1); | ||
|
||
import('./json-idempotency_FIXTURE.json', { with: { type: 'json' } }) | ||
.then(function(viaDynamicImport) { | ||
assert.sameValue(viaDynamicImport.default, viaStaticImport1); | ||
}) | ||
.then($DONE, $DONE); | ||
``` | ||
|
||
## json-idempotency_FIXTURE.json | ||
|
||
```json | ||
{} | ||
``` | ||
|
||
## json-idempotency-indirect_FIXTURE.js | ||
|
||
```js | ||
import value from './json-idempotency_FIXTURE.json' with { type: 'json' }; | ||
|
||
globalThis.viaSecondModule = value; | ||
``` |
3 changes: 3 additions & 0 deletions
3
...utes/json-idempotency-indirect_FIXTURE.js → ...ated/json-idempotency-indirect_FIXTURE.js
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
1 change: 1 addition & 0 deletions
1
...nguage/import/import-attributes/json-idempotency__generated/json-idempotency_FIXTURE.json
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 @@ | ||
{} |
4 changes: 4 additions & 0 deletions
4
...ort/import-attributes/json-idempotency.js → ...butes/json-idempotency__generated/main.js
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
36 changes: 36 additions & 0 deletions
36
test/language/import/import-attributes/json-invalid.multi.md
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,36 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Does not define | ||
info: | | ||
# 1.4 ParseJSONModule ( source ) | ||
The abstract operation ParseJSONModule takes a single argument source which | ||
is a String representing the contents of a module. | ||
1. Let json be ? Call(%JSON.parse%, undefined, « source »). | ||
2. Return CreateDefaultExportSyntheticModule(json). | ||
flags: [module] | ||
features: [import-attributes, json-modules] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
import value from './json-invalid_FIXTURE.json' with { type: 'json' }; | ||
``` | ||
|
||
## json-invalid_FIXTURE.json | ||
|
||
```json | ||
{ | ||
notJson: 0 | ||
} | ||
``` |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
.../import/import-attributes/json-invalid.js → ...ttributes/json-invalid__generated/main.js
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
33 changes: 33 additions & 0 deletions
33
test/language/import/import-attributes/json-named-bindings.multi.md
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,33 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Does not define named bindings | ||
info: | | ||
In the early design of JSON modules, contributors considered allowing the | ||
properties of object values in JSON modules to be imported directly by name. | ||
This was ultimately rejected, so attempting to import in this way should | ||
produce a SyntaxError. | ||
flags: [module] | ||
features: [import-attributes, json-modules] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
import {name} from './json-named-bindings_FIXTURE.json' with { type: 'json' }; | ||
``` | ||
|
||
## json-named-bindings_FIXTURE.json | ||
|
||
```json | ||
{ | ||
"name": 0 | ||
} | ||
``` |
3 changes: 0 additions & 3 deletions
3
test/language/import/import-attributes/json-named-bindings_FIXTURE.json
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.../import/import-attributes/json-named-bindings__generated/json-named-bindings_FIXTURE.json
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,3 @@ | ||
{ | ||
"name": 0 | ||
} |
4 changes: 4 additions & 0 deletions
4
.../import-attributes/json-named-bindings.js → ...es/json-named-bindings__generated/main.js
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
65 changes: 65 additions & 0 deletions
65
test/language/import/import-attributes/json-value-array.multi.md
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,65 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Correctly parses the JSON representation of an array | ||
info: | | ||
# 1.4 ParseJSONModule ( source ) | ||
The abstract operation ParseJSONModule takes a single argument source which | ||
is a String representing the contents of a module. | ||
1. Let json be ? Call(%JSON.parse%, undefined, « source »). | ||
2. Return CreateDefaultExportSyntheticModule(json). | ||
To more fully verify parsing correctness, the source text of the imported | ||
module record includes non-printable characters (specifically, all four forms | ||
of JSON's so-called "whitespace" token) both before and after the "value." | ||
flags: [module] | ||
features: [import-attributes, json-modules] | ||
---*/ | ||
|
||
import value from './json-value-array_FIXTURE.json' with { type: 'json' }; | ||
|
||
assert(Array.isArray(value), 'the exported value is an array'); | ||
assert.sameValue( | ||
Object.getPrototypeOf(value), | ||
Array.prototype, | ||
'the exported value is not a subclass of Array' | ||
); | ||
assert.sameValue(Object.getOwnPropertyNames(value).length, 7); | ||
assert.sameValue(value.length, 6); | ||
|
||
assert.sameValue(value[0], -1.2345); | ||
assert.sameValue(value[1], true); | ||
assert.sameValue(value[2], 'a string value'); | ||
assert.sameValue(value[3], null); | ||
|
||
assert.sameValue(Object.getPrototypeOf(value[4]), Object.prototype); | ||
assert.sameValue(Object.getOwnPropertyNames(value[4]).length, 0); | ||
|
||
assert(Array.isArray(value[5]), 'the fifth element is an array'); | ||
assert.sameValue( | ||
Object.getPrototypeOf(value[5]), | ||
Array.prototype, | ||
'the fifth element is not a subclass of Array' | ||
); | ||
assert.sameValue(Object.getOwnPropertyNames(value[5]).length, 1); | ||
``` | ||
|
||
## json-value-array_FIXTURE.json | ||
|
||
```json | ||
[ | ||
-1234.500e-003, | ||
true, | ||
"a string value", | ||
null, | ||
{}, | ||
[] | ||
] | ||
``` |
6 changes: 2 additions & 4 deletions
6
...-attributes/json-value-array_FIXTURE.json → ...__generated/json-value-array_FIXTURE.json
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
|
||
[ | ||
[ | ||
-1234.500e-003, | ||
true, | ||
"a string value", | ||
null, | ||
{}, | ||
[] | ||
] | ||
] |
4 changes: 4 additions & 0 deletions
4
...ort/import-attributes/json-value-array.js → ...butes/json-value-array__generated/main.js
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
31 changes: 31 additions & 0 deletions
31
test/language/import/import-attributes/json-value-boolean.multi.md
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,31 @@ | ||
Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
This code is governed by the BSD license found in the LICENSE file. | ||
|
||
## main.js | ||
|
||
```js | ||
/*--- | ||
esid: sec-parse-json-module | ||
description: Correctly parses the JSON representation of a boolean | ||
info: | | ||
# 1.4 ParseJSONModule ( source ) | ||
The abstract operation ParseJSONModule takes a single argument source which | ||
is a String representing the contents of a module. | ||
1. Let json be ? Call(%JSON.parse%, undefined, « source »). | ||
2. Return CreateDefaultExportSyntheticModule(json). | ||
flags: [module] | ||
features: [import-attributes, json-modules] | ||
---*/ | ||
|
||
import value from './json-value-boolean_FIXTURE.json' with { type: 'json' }; | ||
|
||
assert.sameValue(value, true); | ||
``` | ||
|
||
## json-value-boolean_FIXTURE.json | ||
|
||
```json | ||
true | ||
``` |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...t/import-attributes/json-value-boolean.js → ...tes/json-value-boolean__generated/main.js
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
Oops, something went wrong.