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

Side by Side Diff: test/cctest/test-utils.cc

Issue 10820047: Make sure double to int conversion is correct. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 CHECK_EQ(0, FastD2I(0.345)); 48 CHECK_EQ(0, FastD2I(0.345));
49 CHECK_EQ(1, FastD2I(1.234)); 49 CHECK_EQ(1, FastD2I(1.234));
50 CHECK_EQ(1000000, FastD2I(1000000.123)); 50 CHECK_EQ(1000000, FastD2I(1000000.123));
51 // Check that >> is implemented as arithmetic shift right. 51 // Check that >> is implemented as arithmetic shift right.
52 // If this is not true, then ArithmeticShiftRight() must be changed, 52 // If this is not true, then ArithmeticShiftRight() must be changed,
53 // There are also documented right shifts in assembler.cc of 53 // There are also documented right shifts in assembler.cc of
54 // int8_t and intptr_t signed integers. 54 // int8_t and intptr_t signed integers.
55 CHECK_EQ(-2, -8 >> 2); 55 CHECK_EQ(-2, -8 >> 2);
56 CHECK_EQ(-2, static_cast<int8_t>(-8) >> 2); 56 CHECK_EQ(-2, static_cast<int8_t>(-8) >> 2);
57 CHECK_EQ(-2, static_cast<int>(static_cast<intptr_t>(-8) >> 2)); 57 CHECK_EQ(-2, static_cast<int>(static_cast<intptr_t>(-8) >> 2));
58
59 CHECK_EQ(-1000000, FastD2IChecked(-1000000.0));
60 CHECK_EQ(-1, FastD2IChecked(-1.0));
61 CHECK_EQ(0, FastD2IChecked(0.0));
62 CHECK_EQ(1, FastD2IChecked(1.0));
63 CHECK_EQ(1000000, FastD2IChecked(1000000.0));
64
65 CHECK_EQ(-1000000, FastD2IChecked(-1000000.123));
66 CHECK_EQ(-1, FastD2IChecked(-1.234));
67 CHECK_EQ(0, FastD2IChecked(0.345));
68 CHECK_EQ(1, FastD2IChecked(1.234));
69 CHECK_EQ(1000000, FastD2IChecked(1000000.123));
70
71 CHECK_EQ(INT_MAX, FastD2IChecked(1.0e100));
72 CHECK_EQ(INT_MIN, FastD2IChecked(-1.0e100));
73 CHECK_EQ(INT_MIN, FastD2IChecked(NAN));
58 } 74 }
59 75
60 76
61 TEST(SNPrintF) { 77 TEST(SNPrintF) {
62 // Make sure that strings that are truncated because of too small 78 // Make sure that strings that are truncated because of too small
63 // buffers are zero-terminated anyway. 79 // buffers are zero-terminated anyway.
64 const char* s = "the quick lazy .... oh forget it!"; 80 const char* s = "the quick lazy .... oh forget it!";
65 int length = StrLength(s); 81 int length = StrLength(s);
66 for (int i = 1; i < length * 2; i++) { 82 for (int i = 1; i < length * 2; i++) {
67 static const char kMarker = static_cast<char>(42); 83 static const char kMarker = static_cast<char>(42);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 TEST(SequenceCollectorRegression) { 216 TEST(SequenceCollectorRegression) {
201 SequenceCollector<char> collector(16); 217 SequenceCollector<char> collector(16);
202 collector.StartSequence(); 218 collector.StartSequence();
203 collector.Add('0'); 219 collector.Add('0');
204 collector.AddBlock( 220 collector.AddBlock(
205 i::Vector<const char>("12345678901234567890123456789012", 32)); 221 i::Vector<const char>("12345678901234567890123456789012", 32));
206 i::Vector<char> seq = collector.EndSequence(); 222 i::Vector<char> seq = collector.EndSequence();
207 CHECK_EQ(0, strncmp("0123456789012345678901234567890123", 223 CHECK_EQ(0, strncmp("0123456789012345678901234567890123",
208 seq.start(), seq.length())); 224 seq.start(), seq.length()));
209 } 225 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698