septima-lang 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +1 -0
- package/package.json +3 -3
- package/dist/src/ast-node.d.ts +0 -98
- package/dist/src/ast-node.js +0 -139
- package/dist/src/extract-message.d.ts +0 -1
- package/dist/src/extract-message.js +0 -10
- package/dist/src/fail-me.d.ts +0 -1
- package/dist/src/fail-me.js +0 -11
- package/dist/src/find-array-method.d.ts +0 -15
- package/dist/src/find-array-method.js +0 -104
- package/dist/src/find-string-method.d.ts +0 -2
- package/dist/src/find-string-method.js +0 -88
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -18
- package/dist/src/location.d.ts +0 -11
- package/dist/src/location.js +0 -3
- package/dist/src/parser.d.ts +0 -44
- package/dist/src/parser.js +0 -458
- package/dist/src/result.d.ts +0 -24
- package/dist/src/result.js +0 -29
- package/dist/src/runtime.d.ts +0 -27
- package/dist/src/runtime.js +0 -343
- package/dist/src/scanner.d.ts +0 -23
- package/dist/src/scanner.js +0 -88
- package/dist/src/septima.d.ts +0 -32
- package/dist/src/septima.js +0 -91
- package/dist/src/should-never-happen.d.ts +0 -1
- package/dist/src/should-never-happen.js +0 -9
- package/dist/src/source-code.d.ts +0 -19
- package/dist/src/source-code.js +0 -90
- package/dist/src/stack.d.ts +0 -11
- package/dist/src/stack.js +0 -19
- package/dist/src/switch-on.d.ts +0 -1
- package/dist/src/switch-on.js +0 -9
- package/dist/src/symbol-table.d.ts +0 -6
- package/dist/src/symbol-table.js +0 -3
- package/dist/src/value.d.ts +0 -128
- package/dist/src/value.js +0 -634
- package/dist/tests/parser.spec.d.ts +0 -1
- package/dist/tests/parser.spec.js +0 -31
- package/dist/tests/septima-compute-module.spec.d.ts +0 -1
- package/dist/tests/septima-compute-module.spec.js +0 -30
- package/dist/tests/septima.spec.d.ts +0 -1
- package/dist/tests/septima.spec.js +0 -774
- package/dist/tests/value.spec.d.ts +0 -1
- package/dist/tests/value.spec.js +0 -355
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/jest-output.json +0 -1
- package/src/a.js +0 -66
- package/src/ast-node.ts +0 -249
- package/src/extract-message.ts +0 -5
- package/src/fail-me.ts +0 -7
- package/src/find-array-method.ts +0 -115
- package/src/find-string-method.ts +0 -84
- package/src/index.ts +0 -1
- package/src/location.ts +0 -13
- package/src/parser.ts +0 -526
- package/src/result.ts +0 -45
- package/src/runtime.ts +0 -360
- package/src/scanner.ts +0 -106
- package/src/septima.ts +0 -114
- package/src/should-never-happen.ts +0 -4
- package/src/source-code.ts +0 -101
- package/src/stack.ts +0 -18
- package/src/switch-on.ts +0 -4
- package/src/symbol-table.ts +0 -7
- package/src/value.ts +0 -742
- package/tests/parser.spec.ts +0 -30
- package/tests/septima-compute-module.spec.ts +0 -33
- package/tests/septima.spec.ts +0 -839
- package/tests/value.spec.ts +0 -387
- package/tsconfig.json +0 -11
package/tests/parser.spec.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { show } from '../src/ast-node'
|
|
2
|
-
import { parse } from '../src/septima'
|
|
3
|
-
|
|
4
|
-
describe('parser', () => {
|
|
5
|
-
test('show()', () => {
|
|
6
|
-
expect(show(parse(`5`))).toEqual('5')
|
|
7
|
-
expect(show(parse(`fun (x) x*9`))).toEqual('fun (x) (x * 9)')
|
|
8
|
-
})
|
|
9
|
-
test('syntax errors', () => {
|
|
10
|
-
expect(() => parse(`a + #$%x`)).toThrowError('Unparsable input at (1:5..8) #$%x')
|
|
11
|
-
expect(() => parse(`{#$%x: 8}`)).toThrowError('Expected an identifier at (1:2..9) #$%x: 8}')
|
|
12
|
-
expect(() => parse(`"foo" "goo"`)).toThrowError('Loitering input at (1:7..11) "goo"')
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
describe('unit', () => {
|
|
16
|
-
test('show', () => {
|
|
17
|
-
expect(show(parse(`import * as foo from './bar';'a'`))).toEqual(`import * as foo from './bar';\n'a'`)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
describe('expression', () => {
|
|
21
|
-
test('show', () => {
|
|
22
|
-
expect(show(parse(`'sunday'`))).toEqual(`'sunday'`)
|
|
23
|
-
expect(show(parse(`true`))).toEqual(`true`)
|
|
24
|
-
expect(show(parse(`500`))).toEqual(`500`)
|
|
25
|
-
expect(show(parse(`sink`))).toEqual(`sink`)
|
|
26
|
-
expect(show(parse(`sink!`))).toEqual(`sink!`)
|
|
27
|
-
expect(show(parse(`sink!!`))).toEqual(`sink!!`)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Septima } from '../src/septima'
|
|
2
|
-
import { shouldNeverHappen } from '../src/should-never-happen'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Runs a Septima program for testing purposes. Throws an error If the program evaluated to `sink`.
|
|
6
|
-
*/
|
|
7
|
-
async function run(mainModule: string, inputs: Record<string, string>) {
|
|
8
|
-
const septima = new Septima()
|
|
9
|
-
const res = septima.computeModule(mainModule, (m: string) => inputs[m])
|
|
10
|
-
if (res.tag === 'ok') {
|
|
11
|
-
return res.value
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (res.tag === 'sink') {
|
|
15
|
-
throw new Error(res.message)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
shouldNeverHappen(res)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('septima-compute-module', () => {
|
|
22
|
-
test('fetches the content of the module to compute from the given callback function', async () => {
|
|
23
|
-
expect(await run('a', { a: `3+8` })).toEqual(11)
|
|
24
|
-
})
|
|
25
|
-
test('can use exported definitions from another module', async () => {
|
|
26
|
-
expect(await run('a', { a: `import * as b from 'b'; 3+b.eight`, b: `let eight = 8; {}` })).toEqual(11)
|
|
27
|
-
})
|
|
28
|
-
test('errors if the path to input from is not a string literal', async () => {
|
|
29
|
-
await expect(run('a', { a: `import * as foo from 500` })).rejects.toThrowError(
|
|
30
|
-
'Expected a string literal at (1:22..24) 500',
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
})
|