Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 14018018: Support Float32x4List in the embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 EXPECT_EQ(api_peer, &peer); 1352 EXPECT_EQ(api_peer, &peer);
1353 Dart_ExitScope(); 1353 Dart_ExitScope();
1354 } 1354 }
1355 EXPECT(peer == 0); 1355 EXPECT(peer == 0);
1356 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1356 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1357 EXPECT(peer == 0); 1357 EXPECT(peer == 0);
1358 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1358 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
1359 EXPECT(peer == 42); 1359 EXPECT(peer == 42);
1360 } 1360 }
1361 1361
1362
1363 static void CheckFloat32x4Data(Dart_Handle obj) {
1364 void* raw_data = NULL;
1365 intptr_t len;
1366 Dart_TypedData_Type type;
1367 EXPECT_VALID(Dart_TypedDataAcquireData(obj, &type, &raw_data, &len));
1368 EXPECT_EQ(kFloat32x4, type);
1369 EXPECT_EQ(len, 10);
1370 float* float_data = reinterpret_cast<float*>(raw_data);
1371 for (int i = 0; i < len * 4; i++) {
1372 EXPECT_EQ(0.0, float_data[i]);
1373 }
1374 EXPECT_VALID(Dart_TypedDataReleaseData(obj));
1375 }
1376
1377
1378 TEST_CASE(Float32x4List) {
1379 const char* kScriptChars =
1380 "import 'dart:typeddata';\n"
1381 "Float32x4List float32x4() {\n"
1382 " return new Float32x4List(10);\n"
1383 "}\n";
1384 // Create a test library and Load up a test script in it.
1385 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1386
1387 Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, NULL);
1388 EXPECT_VALID(obj);
1389 CheckFloat32x4Data(obj);
1390
1391 obj = Dart_NewTypedData(kFloat32x4, 10);
1392 EXPECT_VALID(obj);
1393 CheckFloat32x4Data(obj);
1394
1395 int peer = 0;
1396 float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1397 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1398 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1399 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
1400 obj = Dart_NewExternalTypedData(kFloat32x4,
1401 data,
1402 10,
1403 &peer,
1404 ExternalTypedDataCallbackFinalizer);
1405 CheckFloat32x4Data(obj);
1406 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
1407 EXPECT(peer == 42);
1408 }
1409
1410
1362 #endif 1411 #endif
1363 1412
1364 1413
1365 // Unit test for entering a scope, creating a local handle and exiting 1414 // Unit test for entering a scope, creating a local handle and exiting
1366 // the scope. 1415 // the scope.
1367 UNIT_TEST_CASE(EnterExitScope) { 1416 UNIT_TEST_CASE(EnterExitScope) {
1368 TestIsolateScope __test_isolate__; 1417 TestIsolateScope __test_isolate__;
1369 1418
1370 Isolate* isolate = Isolate::Current(); 1419 Isolate* isolate = Isolate::Current();
1371 EXPECT(isolate != NULL); 1420 EXPECT(isolate != NULL);
(...skipping 6220 matching lines...) Expand 10 before | Expand all | Expand 10 after
7592 NULL); 7641 NULL);
7593 int64_t value = 0; 7642 int64_t value = 0;
7594 result = Dart_IntegerToInt64(result, &value); 7643 result = Dart_IntegerToInt64(result, &value);
7595 EXPECT_VALID(result); 7644 EXPECT_VALID(result);
7596 EXPECT_EQ(260, value); 7645 EXPECT_EQ(260, value);
7597 } 7646 }
7598 7647
7599 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7648 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7600 7649
7601 } // namespace dart 7650 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698