OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
6 | 6 |
7 #include "src/handles.h" | 7 #include "src/handles.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ModuleResult result = DecodeModule(data, data + sizeof(data)); | 194 ModuleResult result = DecodeModule(data, data + sizeof(data)); |
195 EXPECT_OK(result); | 195 EXPECT_OK(result); |
196 EXPECT_EQ(1, result.val->globals.size()); | 196 EXPECT_EQ(1, result.val->globals.size()); |
197 EXPECT_EQ(0, result.val->functions.size()); | 197 EXPECT_EQ(0, result.val->functions.size()); |
198 EXPECT_EQ(0, result.val->data_segments.size()); | 198 EXPECT_EQ(0, result.val->data_segments.size()); |
199 | 199 |
200 const WasmGlobal* global = &result.val->globals.back(); | 200 const WasmGlobal* global = &result.val->globals.back(); |
201 | 201 |
202 EXPECT_EQ(kAstI32, global->type); | 202 EXPECT_EQ(kAstI32, global->type); |
203 EXPECT_EQ(0, global->offset); | 203 EXPECT_EQ(0, global->offset); |
204 EXPECT_EQ(false, global->mutability); | 204 EXPECT_FALSE(global->mutability); |
205 EXPECT_EQ(WasmInitExpr::kI32Const, global->init.kind); | 205 EXPECT_EQ(WasmInitExpr::kI32Const, global->init.kind); |
206 EXPECT_EQ(13, global->init.val.i32_const); | 206 EXPECT_EQ(13, global->init.val.i32_const); |
207 | 207 |
208 if (result.val) delete result.val; | 208 if (result.val) delete result.val; |
209 } | 209 } |
210 | 210 |
211 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); | 211 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); |
212 } | 212 } |
213 | 213 |
214 TEST_F(WasmModuleVerifyTest, Global_invalid_type) { | 214 TEST_F(WasmModuleVerifyTest, Global_invalid_type) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ModuleResult result = DecodeModule(data, data + sizeof(data)); | 314 ModuleResult result = DecodeModule(data, data + sizeof(data)); |
315 EXPECT_OK(result); | 315 EXPECT_OK(result); |
316 EXPECT_EQ(2, result.val->globals.size()); | 316 EXPECT_EQ(2, result.val->globals.size()); |
317 EXPECT_EQ(0, result.val->functions.size()); | 317 EXPECT_EQ(0, result.val->functions.size()); |
318 EXPECT_EQ(0, result.val->data_segments.size()); | 318 EXPECT_EQ(0, result.val->data_segments.size()); |
319 | 319 |
320 const WasmGlobal* g0 = &result.val->globals[0]; | 320 const WasmGlobal* g0 = &result.val->globals[0]; |
321 | 321 |
322 EXPECT_EQ(kAstF32, g0->type); | 322 EXPECT_EQ(kAstF32, g0->type); |
323 EXPECT_EQ(0, g0->offset); | 323 EXPECT_EQ(0, g0->offset); |
324 EXPECT_EQ(false, g0->mutability); | 324 EXPECT_FALSE(g0->mutability); |
325 EXPECT_EQ(WasmInitExpr::kF32Const, g0->init.kind); | 325 EXPECT_EQ(WasmInitExpr::kF32Const, g0->init.kind); |
326 | 326 |
327 const WasmGlobal* g1 = &result.val->globals[1]; | 327 const WasmGlobal* g1 = &result.val->globals[1]; |
328 | 328 |
329 EXPECT_EQ(kAstF64, g1->type); | 329 EXPECT_EQ(kAstF64, g1->type); |
330 EXPECT_EQ(8, g1->offset); | 330 EXPECT_EQ(8, g1->offset); |
331 EXPECT_EQ(true, g1->mutability); | 331 EXPECT_TRUE(g1->mutability); |
332 EXPECT_EQ(WasmInitExpr::kF64Const, g1->init.kind); | 332 EXPECT_EQ(WasmInitExpr::kF64Const, g1->init.kind); |
333 | 333 |
334 if (result.val) delete result.val; | 334 if (result.val) delete result.val; |
335 } | 335 } |
336 | 336 |
337 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); | 337 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); |
338 } | 338 } |
339 | 339 |
340 TEST_F(WasmModuleVerifyTest, OneSignature) { | 340 TEST_F(WasmModuleVerifyTest, OneSignature) { |
341 { | 341 { |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 TEST_F(WasmModuleVerifyTest, InitExpr_global) { | 1284 TEST_F(WasmModuleVerifyTest, InitExpr_global) { |
1285 static const byte data[] = {WASM_INIT_EXPR_GLOBAL(37)}; | 1285 static const byte data[] = {WASM_INIT_EXPR_GLOBAL(37)}; |
1286 WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); | 1286 WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); |
1287 EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind); | 1287 EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind); |
1288 EXPECT_EQ(37, expr.val.global_index); | 1288 EXPECT_EQ(37, expr.val.global_index); |
1289 } | 1289 } |
1290 | 1290 |
1291 } // namespace wasm | 1291 } // namespace wasm |
1292 } // namespace internal | 1292 } // namespace internal |
1293 } // namespace v8 | 1293 } // namespace v8 |
OLD | NEW |