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

Side by Side Diff: vm/object_test.cc

Issue 8963001: Add Double::NewCanonical and Mint::NewCanonical so that it is possible to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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
« vm/object.cc ('K') | « vm/object.cc ('k') | vm/parser.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 5 #include "vm/assert.h"
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 EXPECT_EQ(-1, c.CompareWith(smi2)); 307 EXPECT_EQ(-1, c.CompareWith(smi2));
308 308
309 Bigint& big1 = Bigint::Handle(BigintOperations::NewFromCString( 309 Bigint& big1 = Bigint::Handle(BigintOperations::NewFromCString(
310 "10000000000000000000")); 310 "10000000000000000000"));
311 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString( 311 Bigint& big2 = Bigint::Handle(BigintOperations::NewFromCString(
312 "-10000000000000000000")); 312 "-10000000000000000000"));
313 EXPECT_EQ(-1, a.CompareWith(big1)); 313 EXPECT_EQ(-1, a.CompareWith(big1));
314 EXPECT_EQ(1, a.CompareWith(big2)); 314 EXPECT_EQ(1, a.CompareWith(big2));
315 EXPECT_EQ(-1, c.CompareWith(big1)); 315 EXPECT_EQ(-1, c.CompareWith(big1));
316 EXPECT_EQ(1, c.CompareWith(big2)); 316 EXPECT_EQ(1, c.CompareWith(big2));
317
318 int64_t mint_value = DART_2PART_UINT64_C(0x7FFFFFFF, 100);
319 Mint& mint1 = Mint::Handle(Mint::NewCanonical(mint_value));
320 Mint& mint2 = Mint::Handle(Mint::NewCanonical(mint_value));
321 EXPECT_EQ(mint1.value(), mint_value);
322 EXPECT_EQ(mint2.value(), mint_value);
323 EXPECT_EQ(mint1.raw(), mint2.raw());
317 #endif 324 #endif
318 } 325 }
319 326
320 327
321 TEST_CASE(Double) { 328 TEST_CASE(Double) {
322 { 329 {
323 const double dbl_const = 5.0; 330 const double dbl_const = 5.0;
324 const Double& dbl = Double::Handle(Double::New(dbl_const)); 331 const Double& dbl = Double::Handle(Double::New(dbl_const));
325 Object& dbl_object = Object::Handle(dbl.raw()); 332 Object& dbl_object = Object::Handle(dbl.raw());
326 EXPECT(dbl.IsDouble()); 333 EXPECT(dbl.IsDouble());
(...skipping 13 matching lines...) Expand all
340 { 347 {
341 const double dbl_const = 0.0; 348 const double dbl_const = 0.0;
342 const Double& dbl = Double::Handle(Double::New(dbl_const)); 349 const Double& dbl = Double::Handle(Double::New(dbl_const));
343 Object& dbl_object = Object::Handle(dbl.raw()); 350 Object& dbl_object = Object::Handle(dbl.raw());
344 EXPECT(dbl.IsDouble()); 351 EXPECT(dbl.IsDouble());
345 EXPECT(dbl_object.IsDouble()); 352 EXPECT(dbl_object.IsDouble());
346 EXPECT_EQ(dbl_const, dbl.value()); 353 EXPECT_EQ(dbl_const, dbl.value());
347 } 354 }
348 355
349 { 356 {
357 const double dbl_const = 5.0;
358 const String& dbl_str = String::Handle(String::New("5.0"));
359 const Double& dbl1 = Double::Handle(Double::NewCanonical(dbl_const));
360 const Double& dbl2 = Double::Handle(Double::NewCanonical(dbl_const));
361 const Double& dbl3 = Double::Handle(Double::NewCanonical(dbl_str));
362 EXPECT_EQ(dbl_const, dbl1.value());
363 EXPECT_EQ(dbl_const, dbl2.value());
364 EXPECT_EQ(dbl_const, dbl3.value());
365 EXPECT_EQ(dbl1.raw(), dbl2.raw());
366 EXPECT_EQ(dbl1.raw(), dbl3.raw());
367 }
368
369 {
350 const double dbl_const = 2.0; 370 const double dbl_const = 2.0;
351 const Double& dbl1 = Double::Handle(Double::New(dbl_const)); 371 const Double& dbl1 = Double::Handle(Double::New(dbl_const));
352 const Double& dbl2 = Double::Handle(Double::New(dbl_const)); 372 const Double& dbl2 = Double::Handle(Double::New(dbl_const));
353 EXPECT(dbl1.Equals(dbl2)); 373 EXPECT(dbl1.Equals(dbl2));
354 const Double& dbl3 = Double::Handle(Double::New(3.3)); 374 const Double& dbl3 = Double::Handle(Double::New(3.3));
355 EXPECT(!dbl1.Equals(dbl3)); 375 EXPECT(!dbl1.Equals(dbl3));
356 EXPECT(!dbl1.Equals(Smi::Handle(Smi::New(3)))); 376 EXPECT(!dbl1.Equals(Smi::Handle(Smi::New(3))));
357 EXPECT(!dbl1.Equals(Double::Handle())); 377 EXPECT(!dbl1.Equals(Double::Handle()));
358 } 378 }
359 { 379 {
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 cls = iterator.GetNextClass(); 2277 cls = iterator.GetNextClass();
2258 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); 2278 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw()));
2259 count++; 2279 count++;
2260 } 2280 }
2261 ASSERT(count == 2); 2281 ASSERT(count == 2);
2262 } 2282 }
2263 2283
2264 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2284 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2265 2285
2266 } // namespace dart 2286 } // namespace dart
OLDNEW
« vm/object.cc ('K') | « vm/object.cc ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698