Play

Check-in [435bf2d49e]
Login
Overview
Comment:Add tests for currently missing functionality in codegen
Timelines: family | ancestors | descendants | both | codegen-generic-multiwords
Files: files | file ages | folders
SHA3-256: 435bf2d49e2ee21446fc12992b1d0654130b91e383c08523c4769d206b3d689f
User & Date: robin.hansen on 2020-08-07 14:02:46
Other Links: branch diff | manifest | tags
Context
2020-08-11
12:40
Auto (un)box integers. Still missing nested pattern match in multiwords. check-in: d480690f69 user: robin.hansen tags: codegen-generic-multiwords
2020-08-07
14:02
Add tests for currently missing functionality in codegen check-in: 435bf2d49e user: robin.hansen tags: codegen-generic-multiwords
2020-08-06
10:52
Can now use parens in type signatures for expressing generic types and unions. check-in: 1f6d7fad40 user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified wasm_tests/multiword.test.js from [ddfb268d1f] to [baaf7e2099].

152
153
154
155
156
157
158












































































          sum
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(6);
});



















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
          sum
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(6);
});

test('Int case', async () => {
    const wat = await compiler.toWat(`
        defunion: Bool
        : Int
        : NoInt

        deftype: NoInt

        defmulti: double
        when: Int
          2 *
        when: NoInt
          drop 0

        def: main
        entry: true
        : 4 double
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(4);
});

test('Int match', async () => {
    const wat = await compiler.toWat(`
        defmulti: double
        when: Int( value 0 )
          drop 2
        when: Int
          2 *

        def: main
        entry: true
        : 0 double
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(2);
});

test('Generic case', async () => {
    const wat = await compiler.toWat(`
        defunion: Maybe a
        : a
        : Nil

        deftype: Nil

        defmulti: map
        type: (Maybe a) [ a -- b ] -- (Maybe b)
        when: a
          !
        when: Nil
          drop

        defmulti: with-default
        type: (Maybe a) a -- a
        when: a
          drop
        when: Nil
          swap drop

        def: main
        entry: true
        : 10 
          [ 1 - ] map
          0 with-default
    `);

    const result = await compiler.run(wat, 'main');

    expect(result.stackElement()).toBe(9);
});