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

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

Issue 1284633004: Add Dart_ListGetRange (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk.git@master
Patch Set: improve typos Created 5 years, 4 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
« runtime/vm/dart_api_impl.cc ('K') | « 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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "include/dart_tools_api.h" 9 #include "include/dart_tools_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 result = Dart_ListGetAt(list_access_test_obj, 2); 1361 result = Dart_ListGetAt(list_access_test_obj, 2);
1362 EXPECT_VALID(result); 1362 EXPECT_VALID(result);
1363 result = Dart_IntegerToInt64(result, &value); 1363 result = Dart_IntegerToInt64(result, &value);
1364 EXPECT_VALID(result); 1364 EXPECT_VALID(result);
1365 EXPECT_EQ(30, value); 1365 EXPECT_EQ(30, value);
1366 1366
1367 // Check if we get an exception when accessing beyond limit. 1367 // Check if we get an exception when accessing beyond limit.
1368 result = Dart_ListGetAt(list_access_test_obj, 4); 1368 result = Dart_ListGetAt(list_access_test_obj, 4);
1369 EXPECT(Dart_IsError(result)); 1369 EXPECT(Dart_IsError(result));
1370 1370
1371 // Check if we can get a range of values.
1372 result = Dart_ListGetRange(list_access_test_obj, 8, 4, nullptr);
1373 EXPECT(Dart_IsError(result));
1374
1375 const int kRangeOffset = 1;
1376 const int kRangeLength = 3 - kRangeOffset;
1377 Dart_Handle values[kRangeLength];
1378 result = Dart_ListGetRange(val, kOffset, kRangeLength, values);
1379 EXPECT_VALID(result);
1380
1381 result = Dart_IntegerToInt64(values[0], &value);
1382 EXPECT_VALID(result);
1383 EXPECT_EQ(20, value);
1384
1385 result = Dart_IntegerToInt64(values[1], &value);
1386 EXPECT_VALID(result);
1387 EXPECT_EQ(30, value);
1388
1371 // Check that we get an exception (and not a fatal error) when 1389 // Check that we get an exception (and not a fatal error) when
1372 // calling ListSetAt and ListSetAsBytes with an immutable list. 1390 // calling ListSetAt and ListSetAsBytes with an immutable list.
1373 list_access_test_obj = Dart_Invoke(lib, NewString("immutable"), 0, NULL); 1391 list_access_test_obj = Dart_Invoke(lib, NewString("immutable"), 0, NULL);
1374 EXPECT_VALID(list_access_test_obj); 1392 EXPECT_VALID(list_access_test_obj);
1375 EXPECT(Dart_IsList(list_access_test_obj)); 1393 EXPECT(Dart_IsList(list_access_test_obj));
1376 1394
1377 result = Dart_ListSetAsBytes(list_access_test_obj, 0, native_array, 3); 1395 result = Dart_ListSetAsBytes(list_access_test_obj, 0, native_array, 3);
1378 EXPECT(Dart_IsError(result)); 1396 EXPECT(Dart_IsError(result));
1379 EXPECT(Dart_IsUnhandledExceptionError(result)); 1397 EXPECT(Dart_IsUnhandledExceptionError(result));
1380 1398
(...skipping 7891 matching lines...) Expand 10 before | Expand all | Expand 10 after
9272 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); 9290 Dart_TimelineAsyncEnd("testAsyncEvent", async_id);
9273 9291
9274 // Check that it is in the output. 9292 // Check that it is in the output.
9275 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); 9293 TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
9276 JSONStream js; 9294 JSONStream js;
9277 recorder->PrintJSON(&js); 9295 recorder->PrintJSON(&js);
9278 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); 9296 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString());
9279 } 9297 }
9280 9298
9281 } // namespace dart 9299 } // namespace dart
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698