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

Side by Side Diff: test/mjsunit/to_number_order.js

Issue 149188: Fix the order in which ToNumber is called for some Math functions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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/math.js ('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
(Empty)
1 var x = "";
2 var v = new Object();
3 var w = new Object();
4 var vv = function() { x += "hest"; return 1; }
5 var ww = function() { x += "fisk"; return 2; }
6 v.valueOf = vv;
7 w.valueOf = ww;
8 assertEquals(1, Math.min(v,w));
9 assertEquals("hestfisk", x, "min");
10
11 x = "";
12 assertEquals(2, Math.max(v,w));
13 assertEquals("hestfisk", x, "max");
14
15 x = "";
16 assertEquals(Math.atan2(1, 2), Math.atan2(v, w));
17 // JSC says fiskhest.
18 assertEquals("hestfisk", x, "atan2");
19
20 x = "";
21 assertEquals(1, Math.pow(v, w));
22 assertEquals("hestfisk", x, "pow");
23
24 var year = { valueOf: function() { x += 1; return 2007; } };
25 var month = { valueOf: function() { x += 2; return 2; } };
26 var date = { valueOf: function() { x += 3; return 4; } };
27 var hours = { valueOf: function() { x += 4; return 13; } };
28 var minutes = { valueOf: function() { x += 5; return 50; } };
29 var seconds = { valueOf: function() { x += 6; return 0; } };
30 var ms = { valueOf: function() { x += 7; return 999; } };
31
32 x = "";
33 new Date(year, month, date, hours, minutes, seconds, ms);
34 // JSC fails this one: Returns 12345671234567.
35 assertEquals("1234567", x, "Date");
36
37 x = "";
38 Date(year, month, date, hours, minutes, seconds, ms);
39 assertEquals("", x, "Date not constructor");
40
41 x = "";
42 Date.UTC(year, month, date, hours, minutes, seconds, ms);
43 // JSC fails this one: Returns 12345671234567.
44 assertEquals("1234567", x, "Date.UTC");
45
46 x = "";
47 new Date().setSeconds(seconds, ms);
48 assertEquals("67", x, "Date.UTC");
49
50 x = "";
51 new Date().setSeconds(seconds, ms);
52 assertEquals("67", x, "Date.setSeconds");
53
54 x = "";
55 new Date().setUTCSeconds(seconds, ms);
56 assertEquals("67", x, "Date.setUTCSeconds");
57
58 x = "";
59 new Date().setMinutes(minutes, seconds, ms);
60 assertEquals("567", x, "Date.setMinutes");
61
62 x = "";
63 new Date().setUTCMinutes(minutes, seconds, ms);
64 assertEquals("567", x, "Date.setUTCMinutes");
65
66 x = "";
67 new Date().setHours(hours, minutes, seconds, ms);
68 assertEquals("4567", x, "Date.setHours");
69
70 x = "";
71 new Date().setUTCHours(hours, minutes, seconds, ms);
72 assertEquals("4567", x, "Date.setUTCHours");
73
74 x = "";
75 new Date().setDate(date, hours, minutes, seconds, ms);
76 assertEquals("3", x, "Date.setDate");
77
78 x = "";
79 new Date().setUTCDate(date, hours, minutes, seconds, ms);
80 assertEquals("3", x, "Date.setUTCDate");
81
82 x = "";
83 new Date().setMonth(month, date, hours, minutes, seconds, ms);
84 assertEquals("23", x, "Date.setMonth");
85
86 x = "";
87 new Date().setUTCMonth(month, date, hours, minutes, seconds, ms);
88 assertEquals("23", x, "Date.setUTCMonth");
89
90 x = "";
91 new Date().setFullYear(year, month, date, hours, minutes, seconds, ms);
92 assertEquals("123", x, "Date.setFullYear");
93
94 x = "";
95 new Date().setUTCFullYear(year, month, date, hours, minutes, seconds, ms);
96 assertEquals("123", x, "Date.setUTCFullYear");
97
98 var a = { valueOf: function() { x += "hest"; return 97; } };
99 var b = { valueOf: function() { x += "fisk"; return 98; } };
100 assertEquals("ab", String.fromCharCode(a, b), "String.fromCharCode");
101
102 print("ok");
OLDNEW
« no previous file with comments | « src/math.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698