aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/src/SpecTestsuites/Core/TrapsTest.php
blob: 53f75c9f4a6a31ed978672fc9059d03153d0fc89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<?php

declare(strict_types=1);

namespace Nsfisis\Waddiwasi\Tests\SpecTestsuites\Core;

use Nsfisis\Waddiwasi\Tests\SpecTestsuites\SpecTestsuiteBase;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;

final class TrapsTest extends SpecTestsuiteBase
{
    public function testModule0(): void
    {
        $this->runModuleCommand(
            filename: 'traps.0.wasm',
            name: null,
            line: 5,
        );
    }

    public function testAssertTrap1(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.div_s', 'args' => [['type' => 'i32', 'value' => '1'], ['type' => 'i32', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 16,
        );
    }

    public function testAssertTrap2(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.div_u', 'args' => [['type' => 'i32', 'value' => '1'], ['type' => 'i32', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 17,
        );
    }

    public function testAssertTrap3(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.div_s', 'args' => [['type' => 'i64', 'value' => '1'], ['type' => 'i64', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 18,
        );
    }

    public function testAssertTrap4(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.div_u', 'args' => [['type' => 'i64', 'value' => '1'], ['type' => 'i64', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 19,
        );
    }

    public function testAssertTrap5(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.div_s', 'args' => [['type' => 'i32', 'value' => '2147483648'], ['type' => 'i32', 'value' => '4294967295']]],
            text: 'integer overflow',
            line: 20,
        );
    }

    public function testAssertTrap6(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.div_s', 'args' => [['type' => 'i64', 'value' => '9223372036854775808'], ['type' => 'i64', 'value' => '18446744073709551615']]],
            text: 'integer overflow',
            line: 21,
        );
    }

    public function testModule7(): void
    {
        $this->runModuleCommand(
            filename: 'traps.1.wasm',
            name: null,
            line: 23,
        );
    }

    public function testAssertTrap8(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.rem_s', 'args' => [['type' => 'i32', 'value' => '1'], ['type' => 'i32', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 34,
        );
    }

    public function testAssertTrap9(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.rem_u', 'args' => [['type' => 'i32', 'value' => '1'], ['type' => 'i32', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 35,
        );
    }

    public function testAssertTrap10(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.rem_s', 'args' => [['type' => 'i64', 'value' => '1'], ['type' => 'i64', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 36,
        );
    }

    public function testAssertTrap11(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.rem_u', 'args' => [['type' => 'i64', 'value' => '1'], ['type' => 'i64', 'value' => '0']]],
            text: 'integer divide by zero',
            line: 37,
        );
    }

    public function testModule12(): void
    {
        $this->runModuleCommand(
            filename: 'traps.2.wasm',
            name: null,
            line: 39,
        );
    }

    public function testAssertTrap13(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.trunc_f32_s', 'args' => [['type' => 'f32', 'value' => '2143289344']]],
            text: 'invalid conversion to integer',
            line: 50,
        );
    }

    public function testAssertTrap14(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.trunc_f32_u', 'args' => [['type' => 'f32', 'value' => '2143289344']]],
            text: 'invalid conversion to integer',
            line: 51,
        );
    }

    public function testAssertTrap15(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.trunc_f64_s', 'args' => [['type' => 'f64', 'value' => '9221120237041090560']]],
            text: 'invalid conversion to integer',
            line: 52,
        );
    }

    public function testAssertTrap16(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.trunc_f64_u', 'args' => [['type' => 'f64', 'value' => '9221120237041090560']]],
            text: 'invalid conversion to integer',
            line: 53,
        );
    }

    public function testAssertTrap17(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.trunc_f32_s', 'args' => [['type' => 'f32', 'value' => '2143289344']]],
            text: 'invalid conversion to integer',
            line: 54,
        );
    }

    public function testAssertTrap18(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.trunc_f32_u', 'args' => [['type' => 'f32', 'value' => '2143289344']]],
            text: 'invalid conversion to integer',
            line: 55,
        );
    }

    public function testAssertTrap19(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.trunc_f64_s', 'args' => [['type' => 'f64', 'value' => '9221120237041090560']]],
            text: 'invalid conversion to integer',
            line: 56,
        );
    }

    public function testAssertTrap20(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.trunc_f64_u', 'args' => [['type' => 'f64', 'value' => '9221120237041090560']]],
            text: 'invalid conversion to integer',
            line: 57,
        );
    }

    public function testModule21(): void
    {
        $this->runModuleCommand(
            filename: 'traps.3.wasm',
            name: null,
            line: 59,
        );
    }

    public function testAssertTrap22(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.load', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 78,
        );
    }

    public function testAssertTrap23(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.load16_s', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 79,
        );
    }

    public function testAssertTrap24(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.load16_u', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 80,
        );
    }

    public function testAssertTrap25(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.load8_s', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 81,
        );
    }

    public function testAssertTrap26(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i32.load8_u', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 82,
        );
    }

    public function testAssertTrap27(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 83,
        );
    }

    public function testAssertTrap28(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load32_s', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 84,
        );
    }

    public function testAssertTrap29(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load32_u', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 85,
        );
    }

    public function testAssertTrap30(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load16_s', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 86,
        );
    }

    public function testAssertTrap31(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load16_u', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 87,
        );
    }

    public function testAssertTrap32(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load8_s', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 88,
        );
    }

    public function testAssertTrap33(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.i64.load8_u', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 89,
        );
    }

    public function testAssertTrap34(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.f32.load', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 90,
        );
    }

    public function testAssertTrap35(): void
    {
        $this->runAssertTrapCommand(
            action: ['type' => 'invoke', 'field' => 'no_dce.f64.load', 'args' => [['type' => 'i32', 'value' => '65536']]],
            text: 'out of bounds memory access',
            line: 91,
        );
    }
}