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

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

Issue 14426006: Rename dart:typeddata to dart:typed_data. (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') | runtime/vm/dart_api_message.cc » ('j') | 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 898
899 899
900 static Dart_NativeFunction ByteDataNativeResolver(Dart_Handle name, 900 static Dart_NativeFunction ByteDataNativeResolver(Dart_Handle name,
901 int arg_count) { 901 int arg_count) {
902 return &ByteDataNativeFunction; 902 return &ByteDataNativeFunction;
903 } 903 }
904 904
905 905
906 TEST_CASE(ByteDataAccess) { 906 TEST_CASE(ByteDataAccess) {
907 const char* kScriptChars = 907 const char* kScriptChars =
908 "import 'dart:typeddata';\n" 908 "import 'dart:typed_data';\n"
909 "class Expect {\n" 909 "class Expect {\n"
910 " static equals(a, b) {\n" 910 " static equals(a, b) {\n"
911 " if (a != b) {\n" 911 " if (a != b) {\n"
912 " throw 'not equal. expected: $a, got: $b';\n" 912 " throw 'not equal. expected: $a, got: $b';\n"
913 " }\n" 913 " }\n"
914 " }\n" 914 " }\n"
915 "}\n" 915 "}\n"
916 "ByteData createByteData() native 'CreateByteData';" 916 "ByteData createByteData() native 'CreateByteData';"
917 "ByteData main() {" 917 "ByteData main() {"
918 " var length = 16;" 918 " var length = 16;"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 static Dart_NativeFunction ExternalByteDataNativeResolver(Dart_Handle name, 960 static Dart_NativeFunction ExternalByteDataNativeResolver(Dart_Handle name,
961 int arg_count) { 961 int arg_count) {
962 return &ExternalByteDataNativeFunction; 962 return &ExternalByteDataNativeFunction;
963 } 963 }
964 964
965 965
966 TEST_CASE(ExternalByteDataAccess) { 966 TEST_CASE(ExternalByteDataAccess) {
967 // TODO(asiva): Once we have getInt16LE and getInt16BE support use the 967 // TODO(asiva): Once we have getInt16LE and getInt16BE support use the
968 // appropriate getter instead of the host endian format used now. 968 // appropriate getter instead of the host endian format used now.
969 const char* kScriptChars = 969 const char* kScriptChars =
970 "import 'dart:typeddata';\n" 970 "import 'dart:typed_data';\n"
971 "class Expect {\n" 971 "class Expect {\n"
972 " static equals(a, b) {\n" 972 " static equals(a, b) {\n"
973 " if (a != b) {\n" 973 " if (a != b) {\n"
974 " throw 'not equal. expected: $a, got: $b';\n" 974 " throw 'not equal. expected: $a, got: $b';\n"
975 " }\n" 975 " }\n"
976 " }\n" 976 " }\n"
977 "}\n" 977 "}\n"
978 "ByteData createExternalByteData() native 'CreateExternalByteData';" 978 "ByteData createExternalByteData() native 'CreateExternalByteData';"
979 "ByteData main() {" 979 "ByteData main() {"
980 " var length = 16;" 980 " var length = 16;"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 EXPECT_VALID(result); 1079 EXPECT_VALID(result);
1080 1080
1081 // Invoke the dart function in order to check the modified values. 1081 // Invoke the dart function in order to check the modified values.
1082 result = Dart_Invoke(lib, NewString("testMain"), 1, dart_args); 1082 result = Dart_Invoke(lib, NewString("testMain"), 1, dart_args);
1083 EXPECT_VALID(result); 1083 EXPECT_VALID(result);
1084 } 1084 }
1085 1085
1086 1086
1087 TEST_CASE(TypedDataDirectAccess1) { 1087 TEST_CASE(TypedDataDirectAccess1) {
1088 const char* kScriptChars = 1088 const char* kScriptChars =
1089 "import 'dart:typeddata';\n" 1089 "import 'dart:typed_data';\n"
1090 "class Expect {\n" 1090 "class Expect {\n"
1091 " static equals(a, b) {\n" 1091 " static equals(a, b) {\n"
1092 " if (a != b) {\n" 1092 " if (a != b) {\n"
1093 " throw new Exception('not equal. expected: $a, got: $b');\n" 1093 " throw new Exception('not equal. expected: $a, got: $b');\n"
1094 " }\n" 1094 " }\n"
1095 " }\n" 1095 " }\n"
1096 "}\n" 1096 "}\n"
1097 "void setMain(var a) {" 1097 "void setMain(var a) {"
1098 " for (var i = 0; i < 10; i++) {" 1098 " for (var i = 0; i < 10; i++) {"
1099 " a[i] = i;" 1099 " a[i] = i;"
(...skipping 26 matching lines...) Expand all
1126 data, 1126 data,
1127 data_length, 1127 data_length,
1128 NULL, NULL); 1128 NULL, NULL);
1129 EXPECT_VALID(ext_list_access_test_obj); 1129 EXPECT_VALID(ext_list_access_test_obj);
1130 TestDirectAccess(lib, ext_list_access_test_obj, kUint8); 1130 TestDirectAccess(lib, ext_list_access_test_obj, kUint8);
1131 } 1131 }
1132 1132
1133 1133
1134 TEST_CASE(TypedDataViewDirectAccess) { 1134 TEST_CASE(TypedDataViewDirectAccess) {
1135 const char* kScriptChars = 1135 const char* kScriptChars =
1136 "import 'dart:typeddata';\n" 1136 "import 'dart:typed_data';\n"
1137 "class Expect {\n" 1137 "class Expect {\n"
1138 " static equals(a, b) {\n" 1138 " static equals(a, b) {\n"
1139 " if (a != b) {\n" 1139 " if (a != b) {\n"
1140 " throw 'not equal. expected: $a, got: $b';\n" 1140 " throw 'not equal. expected: $a, got: $b';\n"
1141 " }\n" 1141 " }\n"
1142 " }\n" 1142 " }\n"
1143 "}\n" 1143 "}\n"
1144 "void setMain(var list) {" 1144 "void setMain(var list) {"
1145 " Expect.equals(10, list.length);" 1145 " Expect.equals(10, list.length);"
1146 " for (var i = 0; i < 10; i++) {" 1146 " for (var i = 0; i < 10; i++) {"
(...skipping 18 matching lines...) Expand all
1165 // Test with a typed data view object. 1165 // Test with a typed data view object.
1166 Dart_Handle list_access_test_obj; 1166 Dart_Handle list_access_test_obj;
1167 list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL); 1167 list_access_test_obj = Dart_Invoke(lib, NewString("main"), 0, NULL);
1168 EXPECT_VALID(list_access_test_obj); 1168 EXPECT_VALID(list_access_test_obj);
1169 TestDirectAccess(lib, list_access_test_obj, kInt8); 1169 TestDirectAccess(lib, list_access_test_obj, kInt8);
1170 } 1170 }
1171 1171
1172 1172
1173 TEST_CASE(ByteDataDirectAccess) { 1173 TEST_CASE(ByteDataDirectAccess) {
1174 const char* kScriptChars = 1174 const char* kScriptChars =
1175 "import 'dart:typeddata';\n" 1175 "import 'dart:typed_data';\n"
1176 "class Expect {\n" 1176 "class Expect {\n"
1177 " static equals(a, b) {\n" 1177 " static equals(a, b) {\n"
1178 " if (a != b) {\n" 1178 " if (a != b) {\n"
1179 " throw 'not equal. expected: $a, got: $b';\n" 1179 " throw 'not equal. expected: $a, got: $b';\n"
1180 " }\n" 1180 " }\n"
1181 " }\n" 1181 " }\n"
1182 "}\n" 1182 "}\n"
1183 "void setMain(var list) {" 1183 "void setMain(var list) {"
1184 " Expect.equals(10, list.length);" 1184 " Expect.equals(10, list.length);"
1185 " for (var i = 0; i < 10; i++) {" 1185 " for (var i = 0; i < 10; i++) {"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 float* float_data = reinterpret_cast<float*>(raw_data); 1370 float* float_data = reinterpret_cast<float*>(raw_data);
1371 for (int i = 0; i < len * 4; i++) { 1371 for (int i = 0; i < len * 4; i++) {
1372 EXPECT_EQ(0.0, float_data[i]); 1372 EXPECT_EQ(0.0, float_data[i]);
1373 } 1373 }
1374 EXPECT_VALID(Dart_TypedDataReleaseData(obj)); 1374 EXPECT_VALID(Dart_TypedDataReleaseData(obj));
1375 } 1375 }
1376 1376
1377 1377
1378 TEST_CASE(Float32x4List) { 1378 TEST_CASE(Float32x4List) {
1379 const char* kScriptChars = 1379 const char* kScriptChars =
1380 "import 'dart:typeddata';\n" 1380 "import 'dart:typed_data';\n"
1381 "Float32x4List float32x4() {\n" 1381 "Float32x4List float32x4() {\n"
1382 " return new Float32x4List(10);\n" 1382 " return new Float32x4List(10);\n"
1383 "}\n"; 1383 "}\n";
1384 // Create a test library and Load up a test script in it. 1384 // Create a test library and Load up a test script in it.
1385 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1385 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1386 1386
1387 Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, NULL); 1387 Dart_Handle obj = Dart_Invoke(lib, NewString("float32x4"), 0, NULL);
1388 EXPECT_VALID(obj); 1388 EXPECT_VALID(obj);
1389 CheckFloat32x4Data(obj); 1389 CheckFloat32x4Data(obj);
1390 1390
(...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 NULL); 7641 NULL);
7642 int64_t value = 0; 7642 int64_t value = 0;
7643 result = Dart_IntegerToInt64(result, &value); 7643 result = Dart_IntegerToInt64(result, &value);
7644 EXPECT_VALID(result); 7644 EXPECT_VALID(result);
7645 EXPECT_EQ(260, value); 7645 EXPECT_EQ(260, value);
7646 } 7646 }
7647 7647
7648 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7648 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7649 7649
7650 } // namespace dart 7650 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698