diff --git a/test/case/array.js b/test/case/array.js index 5c2849a..bba1e0d 100644 --- a/test/case/array.js +++ b/test/case/array.js @@ -1,12 +1,12 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('array: basic', t => { - let wat = compileSruti(`x = [1]`) + let wat = compileZ(`x = [1]`) let mod = compileWat(wat) - wat = compileSruti(`x = [1.1, 2.22, 3.333], y = [4.1234,5.54321,654321.123456,7.7777777]; x,y,xl=x[],yl=y[]`) + wat = compileZ(`x = [1.1, 2.22, 3.333], y = [4.1234,5.54321,654321.123456,7.7777777]; x,y,xl=x[],yl=y[]`) mod = compileWat(wat) let { memory, x, y, xl, yl } = mod.instance.exports let xarr = new Float64Array(memory.buffer, x.value, 3) @@ -23,7 +23,7 @@ t('array: basic', t => { }) t('array: basic local', t => { - let wat = compileSruti(`x() = [1, 2]`) + let wat = compileZ(`x() = [1, 2]`) let mod = compileWat(wat) let { memory, x } = mod.instance.exports let x0 = new Float64Array(memory.buffer, x(), 2) @@ -34,7 +34,7 @@ t('array: basic local', t => { }) t.todo('array: from static range', t => { - let wat = compileSruti(`x=[..3], y=[0..4]; z=[4..0], x,y,xl=x[],yl=y[]`) + let wat = compileZ(`x=[..3], y=[0..4]; z=[4..0], x,y,xl=x[],yl=y[]`) // console.log(wat) let mod = compileWat(wat) let { memory, x, y, xl, yl, z } = mod.instance.exports @@ -57,7 +57,7 @@ t.todo('array: from static range', t => { }) t('array: from dynamic range', t => { - let wat = compileSruti(`a=3, x=[0..a], xl=x[]`) + let wat = compileZ(`a=3, x=[0..a], xl=x[]`) // , y=[1, x[0]..x[2], 2..-2]; x,y, xl=x[],yl=y[]`) // console.log(wat) let mod = compileWat(wat) @@ -71,14 +71,14 @@ t('array: from dynamic range', t => { t('array: from invalid ranges', t => { let wat - throws(() => { wat = compileSruti(`x=[2..]`) }, /range/) - throws(() => { wat = compileSruti(`x=[..]`) }, /range/) - throws(() => { wat = compileSruti(`x=[..-2]`) }, /range/) + throws(() => { wat = compileZ(`x=[2..]`) }, /range/) + throws(() => { wat = compileZ(`x=[..]`) }, /range/) + throws(() => { wat = compileZ(`x=[..-2]`) }, /range/) }) t('array: nested static', t => { - let wat = compileSruti(`x=[1, y=[2, [3,3.14]]], w=[4,5]`) - // let wat = compileSruti(`y=[2], x=[1, y], w=[4,5]`) + let wat = compileZ(`x=[1, y=[2, [3,3.14]]], w=[4,5]`) + // let wat = compileZ(`y=[2], x=[1, y], w=[4,5]`) // console.log(wat) let mod = compileWat(wat) let { memory, x, y, w } = mod.instance.exports @@ -101,7 +101,7 @@ t('array: nested static', t => { }) t.todo('array: comprehension', t => { - let wat = compileSruti(`x = [1..3 |> _ * 2]`) + let wat = compileZ(`x = [1..3 |> _ * 2]`) let mod = compileWat(wat) let { memory, x } = mod.instance.exports let xarr = new Float64Array(memory.buffer, x, 2) @@ -109,11 +109,11 @@ t.todo('array: comprehension', t => { }) t.todo('array: nested comprehension', t => { - let wat = compileSruti(`x = [1..3 <| [0.._ <| _ * 2]]`) + let wat = compileZ(`x = [1..3 <| [0.._ <| _ * 2]]`) }) t('array: simple write', t => { - let wat = compileSruti(`x=[..3]; x[0]=1; x[1]=2; x[-1]=x[]; x`) + let wat = compileZ(`x=[..3]; x[0]=1; x[1]=2; x[-1]=x[]; x`) // console.log(wat) let mod = compileWat(wat) let { memory, x } = mod.instance.exports @@ -124,7 +124,7 @@ t('array: simple write', t => { }) t('array: simple read', t => { - let wat = compileSruti(`x = [1, 2, 3]; a=x[0],b=x[1],c=x[2],d=x[-1]`) + let wat = compileZ(`x = [1, 2, 3]; a=x[0],b=x[1],c=x[2],d=x[-1]`) // console.log(wat) let mod = compileWat(wat) let { a, b, c, d } = mod.instance.exports @@ -135,7 +135,7 @@ t('array: simple read', t => { }) t('array: group read', t => { - let wat = compileSruti(`x = [1, 2, 3]; (a,b,c)=x[0,1,2]`) + let wat = compileZ(`x = [1, 2, 3]; (a,b,c)=x[0,1,2]`) // console.log(wat) let mod = compileWat(wat) let { a, b, c } = mod.instance.exports @@ -145,7 +145,7 @@ t('array: group read', t => { }) t('array: group write', t => { - let wat = compileSruti(`x = [..3]; x[0,1,2]=(1,2,3)`) + let wat = compileZ(`x = [..3]; x[0,1,2]=(1,2,3)`) // console.log(wat) let mod = compileWat(wat) let { x, memory } = mod.instance.exports @@ -156,7 +156,7 @@ t('array: group write', t => { }) t('compile: sublist', t => { - let wat = compileSruti(`x = [1,2,3], y = [x]`) + let wat = compileZ(`x = [1,2,3], y = [x]`) let mod = compileWat(wat) let { memory, x, y } = mod.instance.exports let xarr = new Float64Array(memory.buffer, x, 3), yarr = new Float64Array(memory.buffer, y, 1) diff --git a/test/case/comments.js b/test/case/comments.js index 3e394b6..18a80b8 100644 --- a/test/case/comments.js +++ b/test/case/comments.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('comments: base', t => { - let wat = compileSruti(`x(a,w,h)=( + let wat = compileZ(`x(a,w,h)=( a=1 ;; a=2 ), y()=( diff --git a/test/case/cond.js b/test/case/cond.js index 663bdad..1d735f1 100644 --- a/test/case/cond.js +++ b/test/case/cond.js @@ -1,39 +1,39 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('condition: base', t => { let wat, mod - wat = compileSruti(`a=1;b=2;c=a?1:2`) + wat = compileZ(`a=1;b=2;c=a?1:2`) mod = compileWat(wat) is(mod.instance.exports.c.value, 1) - wat = compileSruti(`a=1;b=2;a?c=b;c`) + wat = compileZ(`a=1;b=2;a?c=b;c`) mod = compileWat(wat) is(mod.instance.exports.c.value, 2) - wat = compileSruti(`a=0;b=2;a?c=b;c`) + wat = compileZ(`a=0;b=2;a?c=b;c`) mod = compileWat(wat) is(mod.instance.exports.c.value, 0) - wat = compileSruti(`a=0.0;b=2.1;a?c=b;c`) + wat = compileZ(`a=0.0;b=2.1;a?c=b;c`) mod = compileWat(wat) is(mod.instance.exports.c.value, 0) - wat = compileSruti(`a=0.1;b=2.1;a?c=b;c`) + wat = compileZ(`a=0.1;b=2.1;a?c=b;c`) mod = compileWat(wat) is(mod.instance.exports.c.value, 2.1) - wat = compileSruti(`a=0.0;b=2.1;c=a?b`) + wat = compileZ(`a=0.0;b=2.1;c=a?b`) mod = compileWat(wat) is(mod.instance.exports.c.value, 0) - wat = compileSruti(`a=0.1;b=2.1;c=a?b`) + wat = compileZ(`a=0.1;b=2.1;c=a?b`) mod = compileWat(wat) is(mod.instance.exports.c.value, 2.1) console.log('--------------') - wat = compileSruti(`x(px) = (px < 0 ? px = 0; px)`) + wat = compileZ(`x(px) = (px < 0 ? px = 0; px)`) mod = compileWat(wat) is(mod.instance.exports.x(-10), 0) is(mod.instance.exports.x(10), 10) @@ -41,22 +41,22 @@ t('condition: base', t => { t('compile: conditions - or/and', t => { let wat, mod - wat = compileSruti(`z=1||0`) + wat = compileZ(`z=1||0`) mod = compileWat(wat) is(mod.instance.exports.z.value, 1) - wat = compileSruti(`z=1.2||0.0`) + wat = compileZ(`z=1.2||0.0`) mod = compileWat(wat) is(mod.instance.exports.z.value, 1.2) - wat = compileSruti(`z=1.2||0`) + wat = compileZ(`z=1.2||0`) mod = compileWat(wat) is(mod.instance.exports.z.value, 1.2) - wat = compileSruti(`z=1||0.0`) + wat = compileZ(`z=1||0.0`) mod = compileWat(wat) is(mod.instance.exports.z.value, 1) - wat = compileSruti(`z=1.2&&0.2`) + wat = compileZ(`z=1.2&&0.2`) mod = compileWat(wat) is(mod.instance.exports.z.value, 0.2) - wat = compileSruti(`z=1&&2`) + wat = compileZ(`z=1&&2`) mod = compileWat(wat) is(mod.instance.exports.z.value, 2) }) diff --git a/test/case/defer.js b/test/case/defer.js index cc4ae9f..40ca0b4 100644 --- a/test/case/defer.js +++ b/test/case/defer.js @@ -1,18 +1,18 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('defer: - basics', () => { - let wat = compileSruti(`f()=(*t=0;^t++;t)`) + let wat = compileZ(`f()=(*t=0;^t++;t)`) let mod = compileWat(wat), f = mod.instance.exports.f; is([f(), f(), f()], [0, 1, 2]) - wat = compileSruti(`f()=(*t=0;/t;^++t)`) + wat = compileZ(`f()=(*t=0;/t;^++t)`) mod = compileWat(wat), f = mod.instance.exports.f; is([f(), f(), f()], [0, 1, 2], 'after return') }) t.skip('defer: - errors', () => { - // throws(() => compileSruti(`f()=(*t=0;/t;^++t)`), 'defer after return') - // throws(() => compileSruti(`f()=(^++t;*t=0;)`), 'defer before stateful') + // throws(() => compileZ(`f()=(*t=0;/t;^++t)`), 'defer after return') + // throws(() => compileZ(`f()=(^++t;*t=0;)`), 'defer before stateful') }) diff --git a/test/case/examples.js b/test/case/examples.js index 9fc75e5..03b795f 100644 --- a/test/case/examples.js +++ b/test/case/examples.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.todo('example: audio-gain', t => { - let wat = compileSruti(` + let wat = compileZ(` blockSize = 1024; gain = ([blockSize]data, volume ~ 0..1000) -> [data | x -> x * volume]; `) @@ -11,14 +11,14 @@ t.todo('example: audio-gain', t => { let { gain } = mod.instance.exports is(gain([1, 2, 3], 2), [2, 4, 6]) - // let wat = compileSruti(` + // let wat = compileZ(` // blockSize = 1024; // gain = ([2, blockSize]data, volume ~ 0..1000) -> [data | ch -> (ch | x -> x * volume)]; // `) }) t.todo('example: sine gen', t => { - let wat = compileSruti(analyse(parse(` + let wat = compileZ(analyse(parse(` pi = 3.14; pi2 = pi*2; sampleRate = 44100; diff --git a/test/case/export.js b/test/case/export.js index 83314b2..d6809e1 100644 --- a/test/case/export.js +++ b/test/case/export.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.skip('export: - no junk exports', () => { - let wat = compileSruti(`w()=(); y=[1]; x()=(*i=0), z=[y[0], v=[1]]`) + let wat = compileZ(`w()=(); y=[1]; x()=(*i=0), z=[y[0], v=[1]]`) let mod = compileWat(wat) same(Object.keys(mod.instance.exports), ['memory', 'x', 'z']) }) diff --git a/test/case/funcs.js b/test/case/funcs.js index 9cc0776..fe96194 100644 --- a/test/case/funcs.js +++ b/test/case/funcs.js @@ -1,39 +1,39 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.todo('funcs: oneliners', t => { let wat, mod - wat = compileSruti(`mult(a, b=2) = a * b`) + wat = compileZ(`mult(a, b=2) = a * b`) mod = compileWat(wat) is(mod.instance.exports.mult(2, 4), 8) is(mod.instance.exports.mult(2), 4) - mod = compileWat(compileSruti(` mult(a, b) = (a * b)`)) + mod = compileWat(compileZ(` mult(a, b) = (a * b)`)) is(mod.instance.exports.mult(2, 4), 8) console.log('------') - mod = compileWat(compileSruti(` mult(a, b) = (b; a * b)`)) + mod = compileWat(compileZ(` mult(a, b) = (b; a * b)`)) is(mod.instance.exports.mult(2, 4), 8) - mod = compileWat(compileSruti(` mult(a, b) = (b; a * b;)`)) + mod = compileWat(compileZ(` mult(a, b) = (b; a * b;)`)) is(mod.instance.exports.mult(2, 4), 8) - mod = compileWat(compileSruti(` mult(a, b) = (b; a * b; /)`)) + mod = compileWat(compileZ(` mult(a, b) = (b; a * b; /)`)) is(mod.instance.exports.mult(2, 4), undefined) - mod = compileWat(compileSruti(`f()=( *t; ^t++; t; );`)) + mod = compileWat(compileZ(`f()=( *t; ^t++; t; );`)) is([mod.instance.exports.f(), mod.instance.exports.f()], [0, 1]) }) t('funcs: first line inits local', t => { - let mod = compileWat(compileSruti(`a=1, x() = (a=2)`)) + let mod = compileWat(compileZ(`a=1, x() = (a=2)`)) is(mod.instance.exports.a.value, 1) is(mod.instance.exports.x(), 2) is(mod.instance.exports.a.value, 1) - mod = compileWat(compileSruti(`a=1, x() = (;a=2)`)) + mod = compileWat(compileZ(`a=1, x() = (;a=2)`)) is(mod.instance.exports.a.value, 1) is(mod.instance.exports.x(), 2) is(mod.instance.exports.a.value, 2) diff --git a/test/case/groups.js b/test/case/groups.js index 5614ab4..b0267b7 100644 --- a/test/case/groups.js +++ b/test/case/groups.js @@ -1,48 +1,48 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('group: assign cases', t => { let wat, mod - wat = compileSruti(`a=1;b=2;c=(a,b)`) + wat = compileZ(`a=1;b=2;c=(a,b)`) mod = compileWat(wat) is(mod.instance.exports.c.value, 2, 'c=(a,b)') - wat = compileSruti(`a=1;b=2,c=3;(b,a)=(c,b)`) + wat = compileZ(`a=1;b=2,c=3;(b,a)=(c,b)`) mod = compileWat(wat) is(mod.instance.exports.b.value, 3, '(b,a)=(c,b)') is(mod.instance.exports.a.value, 2) - wat = compileSruti(`a=1;b=2;(c,b)=(a,b);a,b,c`) + wat = compileZ(`a=1;b=2;(c,b)=(a,b);a,b,c`) mod = compileWat(wat) is(mod.instance.exports.c.value, 1, '(c,b)=(a,b)') is(mod.instance.exports.b.value, 2) is(mod.instance.exports.a.value, 1) throws(() => { - wat = compileSruti(`a=1;b=2;(c,a,b)=(a,b)`) + wat = compileZ(`a=1;b=2;(c,a,b)=(a,b)`) mod = compileWat(wat) is(mod.instance.exports.c.value, 1, '(c,a,b)=(a,b)') is(mod.instance.exports.a.value, 2) is(mod.instance.exports.b.value, 2) }, /Mismatch/) - wat = compileSruti(`a=1;b=2;(c,d)=(a,b)`) + wat = compileZ(`a=1;b=2;(c,d)=(a,b)`) mod = compileWat(wat) is(mod.instance.exports.c.value, 1, '(c,d)=(a,b)') is(mod.instance.exports.d.value, 2) - wat = compileSruti(`a=1;b=2;a,(b,b)=a`) + wat = compileZ(`a=1;b=2;a,(b,b)=a`) mod = compileWat(wat) is(mod.instance.exports.b.value, 1, '(b,b)=a') is(mod.instance.exports.a.value, 1) - wat = compileSruti(`a=1;b=2,c;a,(b,c)=a`) + wat = compileZ(`a=1;b=2,c;a,(b,c)=a`) mod = compileWat(wat) is(mod.instance.exports.b.value, 1, '(b,c)=a') is(mod.instance.exports.c.value, 1) - wat = compileSruti(`a=1;b=2,c=3;(a,,c)=(b,b,b)`) + wat = compileZ(`a=1;b=2,c=3;(a,,c)=(b,b,b)`) mod = compileWat(wat) is(mod.instance.exports.a.value, 2, '(a,,c)=(b,b,b)') is(mod.instance.exports.b.value, 2, '(a,,c)=(b,b,b)') @@ -52,47 +52,47 @@ t('group: assign cases', t => { t('group: ops cases', t => { let wat, mod - wat = compileSruti(`f(a) = ((x, y) = (a+2,a-2); x,y)`) + wat = compileZ(`f(a) = ((x, y) = (a+2,a-2); x,y)`) mod = compileWat(wat); is(mod.instance.exports.f(4), [6, 2], `(a,b)=(c+1,c-1)`); - wat = compileSruti(`f(a,b,h) = (a, b) * h`) + wat = compileZ(`f(a,b,h) = (a, b) * h`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 3), [6, 9], `(a, b) * h`); - wat = compileSruti(`f(a,b,h) = h * (a, b)`) + wat = compileZ(`f(a,b,h) = h * (a, b)`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 3), [6, 9], `h * (a, b)`); - wat = compileSruti(`f(a,b,c,d) = (a, b) * (c, d)`) + wat = compileZ(`f(a,b,c,d) = (a, b) * (c, d)`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 4, 5), [8, 15], `(a,b)*(c,d)`); - wat = compileSruti(`f(a,b) = 2 * (a, b) * 3`) + wat = compileZ(`f(a,b) = 2 * (a, b) * 3`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3), [12, 18], `2 * (a, b) * 3`); - wat = compileSruti(`f(a,b,c,d) = (2 * (a, b)) * (c, d)`) + wat = compileZ(`f(a,b,c,d) = (2 * (a, b)) * (c, d)`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 4, 5), [16, 30], `(2 * (a, b)) * (c, d)`); - wat = compileSruti(`f(a,b,c,d) = ((2 * (a, b) * 3) * (c,d))`) + wat = compileZ(`f(a,b,c,d) = ((2 * (a, b) * 3) * (c,d))`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 3, 2), [36, 36], `(2 * (a, b) * 3) * (c, d)`); - wat = compileSruti(`f(a,b,h) = ((a>=h, b>=h) ? (a--, b--); a,b)`) + wat = compileZ(`f(a,b,h) = ((a>=h, b>=h) ? (a--, b--); a,b)`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 3), [2, 2], `(a>=h, b>=h) ? (a--, b--)`); - wat = compileSruti(`f(a,b,h) = ((a,b) * (h + 1))`) + wat = compileZ(`f(a,b,h) = ((a,b) * (h + 1))`) mod = compileWat(wat) is(mod.instance.exports.f(2, 3, 1), [4, 6], `((a,b) * (h + 1))`); - wat = compileSruti(`f(a,b,h) = ((a,b) >= h ? (a,b) = h-1; (a,b))`) + wat = compileZ(`f(a,b,h) = ((a,b) >= h ? (a,b) = h-1; (a,b))`) mod = compileWat(wat) is(mod.instance.exports.f(1, 3, 3), [1, 2], `(a,b) >= h ? (a,b) = h-1`); - wat = compileSruti(`x=[1,2,3]; (a, b, c) = x[0,1,2]`) + wat = compileZ(`x=[1,2,3]; (a, b, c) = x[0,1,2]`) mod = compileWat(wat) is([mod.instance.exports.a.value, mod.instance.exports.b.value, mod.instance.exports.c.value], [1, 2, 3], `(a,b,c)=x[0,1,2]`); }) diff --git a/test/case/import.js b/test/case/import.js index 8adad2e..02e1181 100644 --- a/test/case/import.js +++ b/test/case/import.js @@ -1,11 +1,11 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.todo('import: simple', t => { // FIXME: need to use external imports, not internal const imports = { math: { sin: Math.sin, pi: Math.PI } }; - let wat = compileSruti(`; pi, sinpi(n=1)=sin(pi*n)`, { imports }) + let wat = compileZ(`; pi, sinpi(n=1)=sin(pi*n)`, { imports }) let mod = compileWat(wat, imports) let { pi, sinpi } = mod.instance.exports is(pi.value, Math.PI) diff --git a/test/case/loops.js b/test/case/loops.js index 04339bb..3722a58 100644 --- a/test/case/loops.js +++ b/test/case/loops.js @@ -1,10 +1,10 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('loops: range global', t => { let wat, mod, arr - wat = compileSruti(`x=[1..3]; 0..x[] |> x[_]=_+1; x`) + wat = compileZ(`x=[1..3]; 0..x[] |> x[_]=_+1; x`) mod = compileWat(wat); let { memory, x } = mod.instance.exports arr = new Float64Array(memory.buffer, x.value, 3) @@ -15,7 +15,7 @@ t('loops: range global', t => { t('loops: range local', t => { let wat, mod - wat = compileSruti(`x=[1..3], c = 0, fill() = (0..x[] |> (x[_]++;c++))`) + wat = compileZ(`x=[1..3], c = 0, fill() = (0..x[] |> (x[_]++;c++))`) mod = compileWat(wat) let { memory, x, fill, c } = mod.instance.exports @@ -34,7 +34,7 @@ t('loops: range local', t => { t.todo('loop: current item write', t => { let wat, mod - wat = compileSruti(`x=[1..3]; x[..] |> _+=1; x`) + wat = compileZ(`x=[1..3]; x[..] |> _+=1; x`) mod = compileWat(wat) let { memory, x } = mod.instance.exports arr = new Float64Array(memory.buffer, x.value, 3) @@ -44,7 +44,7 @@ t.todo('loop: current item write', t => { }) t('loop: range in range', t => { - let wat = compileSruti(`a=[..9], f(a,w,h)=( + let wat = compileZ(`a=[..9], f(a,w,h)=( 0..w |> (x=_; 0..h |> (y=_; a[y*w + x] = x+y*w; @@ -61,13 +61,13 @@ t('loop: range in range', t => { }) t.todo('loop: as fn return', () => { - let wat = compileSruti(`x=[1..3]; fill() = (0..x[] |> x[_]=_+1); fill, x`) + let wat = compileZ(`x=[1..3]; fill() = (0..x[] |> x[_]=_+1); fill, x`) }) t t.todo('compile: current item assignment', t => { - let wat = compileSruti(` + let wat = compileZ(` x=[..4]; (i=..3) |> x[i]=i*2`) let mod = compileWat(wat) @@ -82,7 +82,7 @@ t.todo('compile: current item assignment', t => { }) t.todo('loop: in loop', t => { - let wat = compileSruti(` + let wat = compileZ(` x=[..4]; (i=..2) |> ( (j=..2) |> ( @@ -104,7 +104,7 @@ t.todo('loop: in loop', t => { }) t.todo('loop: over list', t => { - let wat = compileSruti(`x = [1,2,3]; y = x <| x -> x * 2`) + let wat = compileZ(`x = [1,2,3]; y = x <| x -> x * 2`) let mod = compileWat(wat) let { memory, y } = mod.instance.exports let arr = new Float64Array(memory.buffer, 0, 3), ptr = y.value @@ -116,7 +116,7 @@ t.todo('loop: over list', t => { t.todo('loop: iterate over range', () => { let wat, mod, memory, a, b - wat = compileSruti(`a = (x = (1, 3..5, a[1..])) |> x;`) + wat = compileZ(`a = (x = (1, 3..5, a[1..])) |> x;`) // supposed to compile to // 0.out ;; output of 0 group // 0.idx = 0 ;; 0 group element index diff --git a/test/case/memory.js b/test/case/memory.js index a8f3bbe..1f38cc0 100644 --- a/test/case/memory.js +++ b/test/case/memory.js @@ -1,10 +1,10 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.skip('memory: grow', t => { // FIXME: possibly add option to export internals - let wat = compileSruti(`grow()=[..8192]`) + let wat = compileZ(`grow()=[..8192]`) let mod = compileWat(wat) let { memory, __mem, grow } = mod.instance.exports for (let i = 1; i < 100; i++) { diff --git a/test/case/operators.js b/test/case/operators.js index 3756b0f..d22f172 100644 --- a/test/case/operators.js +++ b/test/case/operators.js @@ -1,39 +1,39 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('operator: negatives', t => { - let wat = compileSruti(`x=-1`) + let wat = compileZ(`x=-1`) let mod = compileWat(wat) is(mod.instance.exports.x.value, -1) - wat = compileSruti(`x=-1.0`) + wat = compileZ(`x=-1.0`) mod = compileWat(wat) is(mod.instance.exports.x.value, -1) }) t('operator: inc/dec', t => { - let wat = compileSruti(`x=1; y=x++; x,y`) + let wat = compileZ(`x=1; y=x++; x,y`) let mod = compileWat(wat) is(mod.instance.exports.x.value, 2) is(mod.instance.exports.y.value, 1) - wat = compileSruti(`x=1; y=++x; x,y`) + wat = compileZ(`x=1; y=++x; x,y`) mod = compileWat(wat) is(mod.instance.exports.x.value, 2) is(mod.instance.exports.y.value, 2) - wat = compileSruti(`x=0; y=x--; x,y`) + wat = compileZ(`x=0; y=x--; x,y`) mod = compileWat(wat) is(mod.instance.exports.x.value, -1) - wat = compileSruti(`x=1; y=x+=2; x,y`) + wat = compileZ(`x=1; y=x+=2; x,y`) mod = compileWat(wat) is(mod.instance.exports.x.value, 3) is(mod.instance.exports.y.value, 3) - wat = compileSruti(`x=1; y=x-=2; x,y`) + wat = compileZ(`x=1; y=x-=2; x,y`) mod = compileWat(wat) is(mod.instance.exports.x.value, -1) is(mod.instance.exports.y.value, -1) @@ -42,14 +42,14 @@ t('operator: inc/dec', t => { t('operators: pow', t => { // static - let wat = compileSruti(`x=2**(1/2),y=x**3,z=x**-2`) + let wat = compileZ(`x=2**(1/2),y=x**3,z=x**-2`) let mod = compileWat(wat) is(mod.instance.exports.x.value, Math.sqrt(2)) is(mod.instance.exports.y.value, mod.instance.exports.x.value ** 3) almost(mod.instance.exports.z.value, mod.instance.exports.x.value ** -2) // complex - wat = compileSruti(`pow(x,y)=(x**y)`) + wat = compileZ(`pow(x,y)=(x**y)`) mod = compileWat(wat) is(mod.instance.exports.pow(1, 0), 1, '1**0') is(mod.instance.exports.pow(-1, 0), 1, `-1**0`) @@ -79,7 +79,7 @@ t('operators: pow', t => { t('operators: % and %%', t => { - let wat = compileSruti(` + let wat = compileZ(` x(a,b)=( a%b, a%%b diff --git a/test/case/ranges.js b/test/case/ranges.js index c3e3f51..04f5f2f 100644 --- a/test/case/ranges.js +++ b/test/case/ranges.js @@ -1,18 +1,18 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('ranges: clamp', t => { - let wat = compileSruti(`x = 11 ~ 0..10`) + let wat = compileZ(`x = 11 ~ 0..10`) let mod = compileWat(wat) is(mod.instance.exports.x.value, 10) - wat = compileSruti(`x = 0 ~ 1..10`) + wat = compileZ(`x = 0 ~ 1..10`) mod = compileWat(wat) is(mod.instance.exports.x.value, 1) - wat = compileSruti(`clamp(x) = (x ~ 0..10)`) + wat = compileZ(`clamp(x) = (x ~ 0..10)`) mod = compileWat(wat) is(mod.instance.exports.clamp(11), 10) is(mod.instance.exports.clamp(-1), 0) diff --git a/test/case/readme.js b/test/case/readme.js index 223401d..50f7c0b 100644 --- a/test/case/readme.js +++ b/test/case/readme.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('readme: numbers', t => { - let numbers = compileSruti(` + let numbers = compileZ(` a=16, b=0x10, c=0b0; ;; int, hex or binary d=16.0, e=.1, f=1e3, g=2e-3; ;; float a,b,c,d,e,f,g @@ -13,7 +13,7 @@ t('readme: numbers', t => { }) t('readme: standard operators', t => { - let ops = compileSruti(` + let ops = compileZ(` a=3,b=2,c=1; ( o0, o1, o2, o3, o4, o5, o5a, o6, o6a, diff --git a/test/case/scope.js b/test/case/scope.js index a13786a..71c3e02 100644 --- a/test/case/scope.js +++ b/test/case/scope.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('scope: early returns', t => { - let wat = compileSruti(`x(a)=(a ?/-a; 123), y(a)=(a?/12;13.4)`) + let wat = compileZ(`x(a)=(a ?/-a; 123), y(a)=(a?/12;13.4)`) let mod = compileWat(wat) let { memory, x, y, z } = mod.instance.exports is(x(0), 123); @@ -11,19 +11,19 @@ t('scope: early returns', t => { is(y(0), 13.4); is(y(1), 12); - wat = compileSruti(`z(a)=(a ? /11 : /12.1; /13)`) + wat = compileZ(`z(a)=(a ? /11 : /12.1; /13)`) mod = compileWat(wat); z = mod.instance.exports.z is(z(0), 12.1); is(z(1), 11); - wat = compileSruti(`z(a)=(/ a ? 11 : 12.1; /13)`) + wat = compileZ(`z(a)=(/ a ? 11 : 12.1; /13)`) mod = compileWat(wat); z = mod.instance.exports.z is(z(0), 12.1); is(z(1), 11); - wat = compileSruti(`y(a,b)=(a ? /b; a,b)`) + wat = compileZ(`y(a,b)=(a ? /b; a,b)`) mod = compileWat(wat) y = mod.instance.exports.y is(y(1), [NaN, NaN]) diff --git a/test/case/strings.js b/test/case/strings.js index 0c8196b..6a8836f 100644 --- a/test/case/strings.js +++ b/test/case/strings.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t.todo('strings: core', t => { - let wat = compileSruti(`x = "abc"`) + let wat = compileZ(`x = "abc"`) // console.log(wat) let mod = compileWat(wat) let { memory, x } = mod.instance.exports diff --git a/test/case/units.js b/test/case/units.js index 5a9a9aa..f72d675 100644 --- a/test/case/units.js +++ b/test/case/units.js @@ -1,9 +1,9 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('units: core', t => { - let wat = compileSruti(` + let wat = compileZ(` pi = 3.1415; 1k = 1000; 1pi = pi; 1s = 44100; 1m=60s; 1h=60m; 1ms = 0.001s; @@ -19,6 +19,6 @@ t('units: core', t => { t.todo('units: units - errors', t => { // bad expressions // - compileSruti(`1h=1s;1s=44800;`) - compileSruti(`1k=x();`) + compileZ(`1h=1s;1s=44800;`) + compileZ(`1k=x();`) }) diff --git a/test/case/vars.js b/test/case/vars.js index 7f9780f..8369eb5 100644 --- a/test/case/vars.js +++ b/test/case/vars.js @@ -1,5 +1,5 @@ import t, { almost, is, not, ok, same, throws } from 'tst' -import compileSruti from '../../src/compile.js' +import compileZ from '../../src/compile.js' import { compileWat } from '../util.js' t('vars: globals basic', t => { @@ -8,9 +8,9 @@ t('vars: globals basic', t => { // TODO: define globals via group (a,b,c). // FIXME: undefined variable throws error - // throws(() => compileSruti(analyse(parse(`pi2 = pi*2.0;`))), /pi is not defined/) + // throws(() => compileZ(analyse(parse(`pi2 = pi*2.0;`))), /pi is not defined/) - let wat = compileSruti(` + let wat = compileZ(` pi = 3.14; pi2 = pi*2.0; sampleRate = 44100; @@ -24,19 +24,19 @@ t('vars: globals basic', t => { t('vars: globals multiple', () => { // FIXME: must throw - // let wat = compileSruti(`pi, pi2, sampleRate = 3.14, 3.14*2, 44100`) - let wat = compileSruti(`(pi, pi2, sampleRate) = (3.14, 3.14*2, 44100)`) + // let wat = compileZ(`pi, pi2, sampleRate = 3.14, 3.14*2, 44100`) + let wat = compileZ(`(pi, pi2, sampleRate) = (3.14, 3.14*2, 44100)`) let mod = compileWat(wat) is(mod.instance.exports.pi.value, 3.14) is(mod.instance.exports.pi2.value, 3.14 * 2) is(mod.instance.exports.sampleRate.value, 44100) - wat = compileSruti(`(a,b) = (-1, -1.0)`) + wat = compileZ(`(a,b) = (-1, -1.0)`) mod = compileWat(wat) is(mod.instance.exports.a.value, -1) is(mod.instance.exports.b.value, -1) - wat = compileSruti(`(a,b) = (-1, -1.0)`) + wat = compileZ(`(a,b) = (-1, -1.0)`) mod = compileWat(wat) is(mod.instance.exports.a.value, -1) is(mod.instance.exports.b.value, -1) @@ -45,17 +45,17 @@ t('vars: globals multiple', () => { t('vars: globals misc', t => { let wat, x; - x = compileWat(compileSruti(`x;x`)).instance.exports.x // unknown type falls to f64 - x = compileWat(compileSruti(`x=1;x`)).instance.exports.x // int type - x = compileWat(compileSruti(`x=1.0;x`)).instance.exports.x // float type - x = compileWat(compileSruti(`x()=1;x`)).instance.exports.x // func type - x = compileWat(compileSruti(`x=[];x`)).instance.exports.x // arr type - x = compileWat(compileSruti(`x;x=1;x`)).instance.exports.x // late-int type - x = compileWat(compileSruti(`x;x=1.0;x`)).instance.exports.x // late-float type - // x = compileWat(compileSruti(`x;x()=1;x`)).instance.exports.x // late-func type - x = compileWat(compileSruti(`x;x=[];x`)).instance.exports.x // late-arr type + x = compileWat(compileZ(`x;x`)).instance.exports.x // unknown type falls to f64 + x = compileWat(compileZ(`x=1;x`)).instance.exports.x // int type + x = compileWat(compileZ(`x=1.0;x`)).instance.exports.x // float type + x = compileWat(compileZ(`x()=1;x`)).instance.exports.x // func type + x = compileWat(compileZ(`x=[];x`)).instance.exports.x // arr type + x = compileWat(compileZ(`x;x=1;x`)).instance.exports.x // late-int type + x = compileWat(compileZ(`x;x=1.0;x`)).instance.exports.x // late-float type + // x = compileWat(compileZ(`x;x()=1;x`)).instance.exports.x // late-func type + x = compileWat(compileZ(`x;x=[];x`)).instance.exports.x // late-arr type }) t('vars: scoped globals', t => { - is(compileWat(compileSruti(`((x = 2); x)`)).instance.exports.x.value, 2) + is(compileWat(compileZ(`((x = 2); x)`)).instance.exports.x.value, 2) })