-
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.
Fixes bug with transpilinig empty for loop (#519)
- Loading branch information
1 parent
2be26dc
commit bd49753
Showing
3 changed files
with
100 additions
and
6 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,51 @@ | ||
|
||
import { standardizePath as s } from '../../../util'; | ||
import { Program } from '../../../Program'; | ||
import { createSandbox } from 'sinon'; | ||
import { getTestTranspile } from '../../../testHelpers.spec'; | ||
|
||
const sinon = createSandbox(); | ||
|
||
describe('ForStatement', () => { | ||
let rootDir = s`${process.cwd()}/.tmp/rootDir`; | ||
let program: Program; | ||
let testTranspile = getTestTranspile(() => [program, rootDir]); | ||
|
||
beforeEach(() => { | ||
program = new Program({ rootDir: rootDir, sourceMap: true }); | ||
}); | ||
afterEach(() => { | ||
sinon.restore(); | ||
program.dispose(); | ||
}); | ||
|
||
it('transpiles a simple loop', () => { | ||
testTranspile(` | ||
sub main() | ||
for i = 0 to 10 | ||
print i | ||
end for | ||
end sub | ||
`); | ||
}); | ||
|
||
it('transpiles with a for loop with a step value', () => { | ||
testTranspile(` | ||
sub main() | ||
for i = 0 to 10 step 2 | ||
print i | ||
end for | ||
end sub | ||
`); | ||
}); | ||
|
||
it('adds newline to end of empty loop declaration', () => { | ||
testTranspile(` | ||
sub main() | ||
for i = 0 to 10 | ||
end for | ||
end sub | ||
`); | ||
}); | ||
|
||
}); |
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,41 @@ | ||
|
||
import { standardizePath as s } from '../../../util'; | ||
import { Program } from '../../../Program'; | ||
import { createSandbox } from 'sinon'; | ||
import { getTestTranspile } from '../../../testHelpers.spec'; | ||
|
||
const sinon = createSandbox(); | ||
|
||
describe('ForEachStatement', () => { | ||
let rootDir = s`${process.cwd()}/.tmp/rootDir`; | ||
let program: Program; | ||
let testTranspile = getTestTranspile(() => [program, rootDir]); | ||
|
||
beforeEach(() => { | ||
program = new Program({ rootDir: rootDir, sourceMap: true }); | ||
}); | ||
afterEach(() => { | ||
sinon.restore(); | ||
program.dispose(); | ||
}); | ||
|
||
it('transpiles a simple loop', () => { | ||
testTranspile(` | ||
sub doLoop(data) | ||
for each i in data | ||
print i | ||
end for | ||
end sub | ||
`); | ||
}); | ||
|
||
it('adds newline to end of empty loop declaration', () => { | ||
testTranspile(` | ||
sub doLoop(data) | ||
for each i in data | ||
end for | ||
end sub | ||
`); | ||
}); | ||
|
||
}); |