septima-lang 0.0.6 → 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.
Files changed (72) hide show
  1. package/main.js +1 -0
  2. package/package.json +3 -3
  3. package/dist/src/ast-node.d.ts +0 -98
  4. package/dist/src/ast-node.js +0 -139
  5. package/dist/src/extract-message.d.ts +0 -1
  6. package/dist/src/extract-message.js +0 -10
  7. package/dist/src/fail-me.d.ts +0 -1
  8. package/dist/src/fail-me.js +0 -11
  9. package/dist/src/find-array-method.d.ts +0 -15
  10. package/dist/src/find-array-method.js +0 -104
  11. package/dist/src/find-string-method.d.ts +0 -2
  12. package/dist/src/find-string-method.js +0 -88
  13. package/dist/src/index.d.ts +0 -1
  14. package/dist/src/index.js +0 -18
  15. package/dist/src/location.d.ts +0 -11
  16. package/dist/src/location.js +0 -3
  17. package/dist/src/parser.d.ts +0 -44
  18. package/dist/src/parser.js +0 -462
  19. package/dist/src/result.d.ts +0 -24
  20. package/dist/src/result.js +0 -29
  21. package/dist/src/runtime.d.ts +0 -28
  22. package/dist/src/runtime.js +0 -347
  23. package/dist/src/scanner.d.ts +0 -23
  24. package/dist/src/scanner.js +0 -88
  25. package/dist/src/septima.d.ts +0 -32
  26. package/dist/src/septima.js +0 -91
  27. package/dist/src/should-never-happen.d.ts +0 -1
  28. package/dist/src/should-never-happen.js +0 -9
  29. package/dist/src/source-code.d.ts +0 -19
  30. package/dist/src/source-code.js +0 -90
  31. package/dist/src/stack.d.ts +0 -11
  32. package/dist/src/stack.js +0 -19
  33. package/dist/src/switch-on.d.ts +0 -1
  34. package/dist/src/switch-on.js +0 -9
  35. package/dist/src/symbol-table.d.ts +0 -6
  36. package/dist/src/symbol-table.js +0 -3
  37. package/dist/src/value.d.ts +0 -128
  38. package/dist/src/value.js +0 -634
  39. package/dist/tests/parser.spec.d.ts +0 -1
  40. package/dist/tests/parser.spec.js +0 -31
  41. package/dist/tests/septima-compute-module.spec.d.ts +0 -1
  42. package/dist/tests/septima-compute-module.spec.js +0 -36
  43. package/dist/tests/septima.spec.d.ts +0 -1
  44. package/dist/tests/septima.spec.js +0 -807
  45. package/dist/tests/value.spec.d.ts +0 -1
  46. package/dist/tests/value.spec.js +0 -355
  47. package/dist/tsconfig.tsbuildinfo +0 -1
  48. package/jest-output.json +0 -1
  49. package/src/a.js +0 -66
  50. package/src/ast-node.ts +0 -249
  51. package/src/extract-message.ts +0 -5
  52. package/src/fail-me.ts +0 -7
  53. package/src/find-array-method.ts +0 -115
  54. package/src/find-string-method.ts +0 -84
  55. package/src/index.ts +0 -1
  56. package/src/location.ts +0 -13
  57. package/src/parser.ts +0 -530
  58. package/src/result.ts +0 -45
  59. package/src/runtime.ts +0 -365
  60. package/src/scanner.ts +0 -106
  61. package/src/septima.ts +0 -121
  62. package/src/should-never-happen.ts +0 -4
  63. package/src/source-code.ts +0 -101
  64. package/src/stack.ts +0 -18
  65. package/src/switch-on.ts +0 -4
  66. package/src/symbol-table.ts +0 -7
  67. package/src/value.ts +0 -742
  68. package/tests/parser.spec.ts +0 -30
  69. package/tests/septima-compute-module.spec.ts +0 -41
  70. package/tests/septima.spec.ts +0 -880
  71. package/tests/value.spec.ts +0 -387
  72. package/tsconfig.json +0 -11
@@ -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,41 +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>, args: Record<string, unknown> = {}) {
8
- const septima = new Septima()
9
- const res = septima.computeModule(mainModule, (m: string) => inputs[m], args)
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
- test('support the passing of args into the runtime', async () => {
34
- expect(await run('a', { a: `args.x * args.y` }, { x: 5, y: 9 })).toEqual(45)
35
- })
36
- test('the args object is available only at the main module', async () => {
37
- await expect(
38
- run('a', { a: `import * as b from 'b'; args.x + '_' + b.foo`, b: `let foo = args.x ?? 'N/A'; {}` }, { x: 'Red' }),
39
- ).rejects.toThrowError(/Symbol args was not found when evaluating/)
40
- })
41
- })