-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for optimized output (#373)
- Loading branch information
Showing
7 changed files
with
81 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../lib |
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,47 @@ | ||
import { YargsParser } from './lib/yargs-parser' | ||
|
||
const parser = new YargsParser({ | ||
cwd: () => { return '' }, | ||
format: (str, arg) => { return str.replace('%s', arg) }, | ||
normalize: (str) => { return str }, | ||
resolve: (str) => { return str }, | ||
require: () => { | ||
throw Error('loading config from files not currently supported in browser') | ||
}, | ||
env: () => {} | ||
}) | ||
|
||
// Workaround the need for proper nodejs typings and externs | ||
// eslint-disable-next-line no-eval | ||
const anyDeepEqual = eval('require("assert").strict.deepEqual') as any | ||
function deepEqual<T> (actual: T, expected: T, message?: string): void { | ||
anyDeepEqual(actual, expected, message) | ||
} | ||
|
||
// Quoted properties aren't allowed in these lint settings. | ||
const FLAG_X = 'x' | ||
|
||
function runTests () { | ||
deepEqual(parser.parse([]).argv, { _: [] }, 'empty argv') | ||
deepEqual( | ||
parser.parse([`--${FLAG_X}=42`]).argv, | ||
{ _: [], [FLAG_X]: 42 }, | ||
'guessed numeric value') | ||
deepEqual( | ||
parser.parse([`--${FLAG_X}=str`]).argv, | ||
{ _: [], [FLAG_X]: 'str' }, | ||
'guessed string value') | ||
deepEqual( | ||
parser.parse([`--no-${FLAG_X}`]).argv, | ||
{ _: [], [FLAG_X]: false }, | ||
'guessed boolean negation') | ||
|
||
// Default values for types: | ||
deepEqual( | ||
parser.parse([`--${FLAG_X}`]).argv, | ||
{ _: [], [FLAG_X]: true }, | ||
'guessed boolean default true') | ||
|
||
console.log('ok') | ||
} | ||
runTests() |
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,8 @@ | ||
{ | ||
"name": "optimized-test", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@tscc/tscc": "^0.6.4", | ||
"@types/node": "^10.0.3" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"modules": { | ||
"out": "optimized.ts" | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"moduleResolution": "node" | ||
}, | ||
"include": [ | ||
"./*.ts", | ||
"./lib/**/*.ts" | ||
] | ||
} |