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

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

Issue 9363018: Add integer min/max constants to globals.h (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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/bigint_operations_test.cc ('k') | runtime/vm/object_test.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/utils.h" 7 #include "platform/utils.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/thread.h" 10 #include "vm/thread.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 EXPECT_EQ(kIntegerVal2, out); 354 EXPECT_EQ(kIntegerVal2, out);
355 355
356 const char* chars = NULL; 356 const char* chars = NULL;
357 result = Dart_IntegerToHexCString(val3, &chars); 357 result = Dart_IntegerToHexCString(val3, &chars);
358 EXPECT_VALID(result); 358 EXPECT_VALID(result);
359 EXPECT(!strcmp(kIntegerVal3, chars)); 359 EXPECT(!strcmp(kIntegerVal3, chars));
360 } 360 }
361 361
362 362
363 TEST_CASE(IntegerFitsIntoInt64) { 363 TEST_CASE(IntegerFitsIntoInt64) {
364 Dart_Handle max = Dart_NewInteger(DART_INT64_C(0x7FFFFFFFFFFFFFFF)); 364 Dart_Handle max = Dart_NewInteger(kMaxInt64);
365 EXPECT(Dart_IsInteger(max)); 365 EXPECT(Dart_IsInteger(max));
366 bool fits = false; 366 bool fits = false;
367 Dart_Handle result = Dart_IntegerFitsIntoInt64(max, &fits); 367 Dart_Handle result = Dart_IntegerFitsIntoInt64(max, &fits);
368 EXPECT_VALID(result); 368 EXPECT_VALID(result);
369 EXPECT(fits); 369 EXPECT(fits);
370 370
371 Dart_Handle above_max = Dart_NewIntegerFromHexCString("0x8000000000000000"); 371 Dart_Handle above_max = Dart_NewIntegerFromHexCString("0x8000000000000000");
372 EXPECT(Dart_IsInteger(above_max)); 372 EXPECT(Dart_IsInteger(above_max));
373 fits = true; 373 fits = true;
374 result = Dart_IntegerFitsIntoInt64(above_max, &fits); 374 result = Dart_IntegerFitsIntoInt64(above_max, &fits);
375 EXPECT_VALID(result); 375 EXPECT_VALID(result);
376 EXPECT(!fits); 376 EXPECT(!fits);
377 377
378 Dart_Handle min = Dart_NewInteger(DART_INT64_C(-0x8000000000000000)); 378 Dart_Handle min = Dart_NewInteger(kMaxInt64);
379 EXPECT(Dart_IsInteger(min)); 379 EXPECT(Dart_IsInteger(min));
380 fits = false; 380 fits = false;
381 result = Dart_IntegerFitsIntoInt64(min, &fits); 381 result = Dart_IntegerFitsIntoInt64(min, &fits);
382 EXPECT_VALID(result); 382 EXPECT_VALID(result);
383 EXPECT(fits); 383 EXPECT(fits);
384 384
385 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-0x8000000000000001"); 385 Dart_Handle below_min = Dart_NewIntegerFromHexCString("-0x8000000000000001");
386 EXPECT(Dart_IsInteger(below_min)); 386 EXPECT(Dart_IsInteger(below_min));
387 fits = true; 387 fits = true;
388 result = Dart_IntegerFitsIntoInt64(below_min, &fits); 388 result = Dart_IntegerFitsIntoInt64(below_min, &fits);
(...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3224 // We should have received the expected number of interrupts. 3224 // We should have received the expected number of interrupts.
3225 EXPECT_EQ(kInterruptCount, interrupt_count); 3225 EXPECT_EQ(kInterruptCount, interrupt_count);
3226 3226
3227 // Give the spawned thread enough time to properly exit. 3227 // Give the spawned thread enough time to properly exit.
3228 Isolate::SetInterruptCallback(saved); 3228 Isolate::SetInterruptCallback(saved);
3229 } 3229 }
3230 3230
3231 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3231 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3232 3232
3233 } // namespace dart 3233 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bigint_operations_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698