-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parser and transpile functionality
- Loading branch information
1 parent
d71e614
commit f8a6c1d
Showing
3 changed files
with
103 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
54 changes: 54 additions & 0 deletions
54
src/parser/tests/expression/RegexLiteralExpression.spec.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,54 @@ | ||
import { Program } from '../../../Program'; | ||
import { standardizePath as s } from '../../../util'; | ||
import { getTestTranspile } from '../../../testHelpers.spec'; | ||
|
||
describe('RegexLiteralExpression', () => { | ||
let rootDir = s`${process.cwd()}/rootDir`; | ||
let program: Program; | ||
let testTranspile = getTestTranspile(() => [program, rootDir]); | ||
|
||
beforeEach(() => { | ||
program = new Program({ rootDir: rootDir }); | ||
}); | ||
afterEach(() => { | ||
program.dispose(); | ||
}); | ||
|
||
describe('transpile', () => { | ||
it('captures flags', () => { | ||
testTranspile(` | ||
sub main() | ||
print /hello/gi | ||
end sub | ||
`, ` | ||
sub main() | ||
print CreateObject("roRegex", "hello", "gi") | ||
end sub | ||
`); | ||
}); | ||
|
||
it('handles when no flags', () => { | ||
testTranspile(` | ||
sub main() | ||
print /hello/ | ||
end sub | ||
`, ` | ||
sub main() | ||
print CreateObject("roRegex", "hello", "") | ||
end sub | ||
`); | ||
}); | ||
|
||
it('handles weird escapes', () => { | ||
testTranspile(` | ||
sub main() | ||
print /\\r\\n\\// | ||
end sub | ||
`, ` | ||
sub main() | ||
print CreateObject("roRegex", "\\r\\n\\/", "") | ||
end sub | ||
`); | ||
}); | ||
}); | ||
}); |