-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
362 additions
and
3 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
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,50 @@ | ||
import {describe, it, expect} from 'vitest'; | ||
import {evaluateSource} from '../../parser'; | ||
import {Interval} from '../../interval'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function parseSource(source: string) { | ||
const visitor = evaluateSource(source, false); | ||
return visitor.mutables.get('$') as Interval[]; | ||
} | ||
|
||
function expand(source: string) { | ||
const visitor = evaluateSource(source, false); | ||
return visitor.expand(visitor.rootContext!).split('\n'); | ||
} | ||
|
||
describe('SonicWeave module system', () => { | ||
it('declares modules and imports from them', () => { | ||
const scale = expand(` | ||
module foo { | ||
"This is a module docstring."; | ||
export const bar = 1; | ||
export riff baz(qux) { | ||
return qux + bar; | ||
} | ||
3/2 "module scale should be ignored"; | ||
} | ||
{ | ||
import * from foo; | ||
bar; // 1 | ||
module corge { | ||
2/1 "block-scope modules make little sense, but banning them is more work." | ||
export * from foo; | ||
} | ||
import baz as grault from corge; | ||
grault(10); // 11 | ||
} | ||
import bar, baz as quux from foo; | ||
quux(100); // 101 | ||
bar + 1000; // 1001 | ||
`); | ||
expect(scale).toEqual(['1', '11', '101', '1001']); | ||
}); | ||
}); |
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.