|
| 1 | + |
| 2 | +if (typeof exports != "undefined") { |
| 3 | + var driver = require("./driver.js"); |
| 4 | + var test = driver.test, testFail = driver.testFail; |
| 5 | + var acorn = require("../acorn"); |
| 6 | +} |
| 7 | + |
| 8 | +//------------------------------------------------------------------------------ |
| 9 | +// export * as ns from "source" |
| 10 | +//------------------------------------------------------------------------------ |
| 11 | + |
| 12 | +test("export * as ns from \"source\"", { |
| 13 | + "type": "Program", |
| 14 | + "start": 0, |
| 15 | + "end": 28, |
| 16 | + "body": [ |
| 17 | + { |
| 18 | + "type": "ExportAllDeclaration", |
| 19 | + "start": 0, |
| 20 | + "end": 28, |
| 21 | + "exported": { |
| 22 | + "type": "Identifier", |
| 23 | + "start": 12, |
| 24 | + "end": 14, |
| 25 | + "name": "ns" |
| 26 | + }, |
| 27 | + "source": { |
| 28 | + "type": "Literal", |
| 29 | + "start": 20, |
| 30 | + "end": 28, |
| 31 | + "value": "source", |
| 32 | + "raw": "\"source\"" |
| 33 | + } |
| 34 | + } |
| 35 | + ], |
| 36 | + "sourceType": "module" |
| 37 | +}, { sourceType: "module", ecmaVersion: 11 }) |
| 38 | + |
| 39 | +test("export * as foo from \"bar\"", { |
| 40 | + "type": "Program", |
| 41 | + "start": 0, |
| 42 | + "end": 26, |
| 43 | + "body": [ |
| 44 | + { |
| 45 | + "type": "ExportAllDeclaration", |
| 46 | + "start": 0, |
| 47 | + "end": 26, |
| 48 | + "exported": { |
| 49 | + "type": "Identifier", |
| 50 | + "start": 12, |
| 51 | + "end": 15, |
| 52 | + "name": "foo" |
| 53 | + }, |
| 54 | + "source": { |
| 55 | + "type": "Literal", |
| 56 | + "start": 21, |
| 57 | + "end": 26, |
| 58 | + "value": "bar", |
| 59 | + "raw": "\"bar\"" |
| 60 | + } |
| 61 | + } |
| 62 | + ], |
| 63 | + "sourceType": "module" |
| 64 | +}, { sourceType: "module", ecmaVersion: 11 }) |
| 65 | + |
| 66 | +test("export * from \"source\"", { |
| 67 | + "type": "Program", |
| 68 | + "start": 0, |
| 69 | + "end": 22, |
| 70 | + "body": [ |
| 71 | + { |
| 72 | + "type": "ExportAllDeclaration", |
| 73 | + "start": 0, |
| 74 | + "end": 22, |
| 75 | + "exported": null, |
| 76 | + "source": { |
| 77 | + "type": "Literal", |
| 78 | + "start": 14, |
| 79 | + "end": 22, |
| 80 | + "value": "source", |
| 81 | + "raw": "\"source\"" |
| 82 | + } |
| 83 | + } |
| 84 | + ], |
| 85 | + "sourceType": "module" |
| 86 | +}, { sourceType: "module", ecmaVersion: 11 }) |
| 87 | + |
| 88 | +testFail("export * as ns from \"source\"", "'import' and 'export' may appear only with 'sourceType: module' (1:0)", { sourceType: "script", ecmaVersion: 11 }) |
| 89 | +testFail("export * as ns from \"source\"", "Unexpected token (1:9)", { sourceType: "module", ecmaVersion: 10 }) |
| 90 | +testFail("export * as ns", "Unexpected token (1:14)", { sourceType: "module", ecmaVersion: 11 }) |
| 91 | +testFail("export * as from \"source\"", "Unexpected token (1:17)", { sourceType: "module", ecmaVersion: 11 }) |
| 92 | +testFail("export * as ns \"source\"", "Unexpected token (1:15)", { sourceType: "module", ecmaVersion: 11 }) |
| 93 | +testFail("export {} as ns from \"source\"", "Unexpected token (1:10)", { sourceType: "module", ecmaVersion: 11 }) |
0 commit comments