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

Side by Side Diff: test/cctest/compiler/test-run-intrinsics.cc

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 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 | « test/cctest/compiler/test-run-deopt.cc ('k') | test/cctest/compiler/test-run-jsbranches.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "test/cctest/compiler/function-tester.h"
8
9 using namespace v8::internal;
10 using namespace v8::internal::compiler;
11
12
13 TEST(IsSmi) {
14 FunctionTester T("(function(a) { return %_IsSmi(a); })");
15
16 T.CheckTrue(T.Val(1));
17 T.CheckFalse(T.Val(1.1));
18 T.CheckFalse(T.Val(-0.0));
19 T.CheckTrue(T.Val(-2));
20 T.CheckFalse(T.Val(-2.3));
21 T.CheckFalse(T.undefined());
22 }
23
24
25 TEST(IsNonNegativeSmi) {
26 FunctionTester T("(function(a) { return %_IsNonNegativeSmi(a); })");
27
28 T.CheckTrue(T.Val(1));
29 T.CheckFalse(T.Val(1.1));
30 T.CheckFalse(T.Val(-0.0));
31 T.CheckFalse(T.Val(-2));
32 T.CheckFalse(T.Val(-2.3));
33 T.CheckFalse(T.undefined());
34 }
35
36
37 TEST(IsMinusZero) {
38 FunctionTester T("(function(a) { return %_IsMinusZero(a); })");
39
40 T.CheckFalse(T.Val(1));
41 T.CheckFalse(T.Val(1.1));
42 T.CheckTrue(T.Val(-0.0));
43 T.CheckFalse(T.Val(-2));
44 T.CheckFalse(T.Val(-2.3));
45 T.CheckFalse(T.undefined());
46 }
47
48
49 TEST(IsArray) {
50 FunctionTester T("(function(a) { return %_IsArray(a); })");
51
52 T.CheckFalse(T.NewObject("(function() {})"));
53 T.CheckTrue(T.NewObject("([1])"));
54 T.CheckFalse(T.NewObject("({})"));
55 T.CheckFalse(T.NewObject("(/x/)"));
56 T.CheckFalse(T.undefined());
57 T.CheckFalse(T.null());
58 T.CheckFalse(T.Val("x"));
59 T.CheckFalse(T.Val(1));
60 }
61
62
63 TEST(IsObject) {
64 FunctionTester T("(function(a) { return %_IsObject(a); })");
65
66 T.CheckFalse(T.NewObject("(function() {})"));
67 T.CheckTrue(T.NewObject("([1])"));
68 T.CheckTrue(T.NewObject("({})"));
69 T.CheckTrue(T.NewObject("(/x/)"));
70 T.CheckFalse(T.undefined());
71 T.CheckTrue(T.null());
72 T.CheckFalse(T.Val("x"));
73 T.CheckFalse(T.Val(1));
74 }
75
76
77 TEST(IsFunction) {
78 FunctionTester T("(function(a) { return %_IsFunction(a); })");
79
80 T.CheckTrue(T.NewObject("(function() {})"));
81 T.CheckFalse(T.NewObject("([1])"));
82 T.CheckFalse(T.NewObject("({})"));
83 T.CheckFalse(T.NewObject("(/x/)"));
84 T.CheckFalse(T.undefined());
85 T.CheckFalse(T.null());
86 T.CheckFalse(T.Val("x"));
87 T.CheckFalse(T.Val(1));
88 }
89
90
91 TEST(IsRegExp) {
92 FunctionTester T("(function(a) { return %_IsRegExp(a); })");
93
94 T.CheckFalse(T.NewObject("(function() {})"));
95 T.CheckFalse(T.NewObject("([1])"));
96 T.CheckFalse(T.NewObject("({})"));
97 T.CheckTrue(T.NewObject("(/x/)"));
98 T.CheckFalse(T.undefined());
99 T.CheckFalse(T.null());
100 T.CheckFalse(T.Val("x"));
101 T.CheckFalse(T.Val(1));
102 }
103
104
105 TEST(ClassOf) {
106 FunctionTester T("(function(a) { return %_ClassOf(a); })");
107
108 T.CheckCall(T.Val("Function"), T.NewObject("(function() {})"));
109 T.CheckCall(T.Val("Array"), T.NewObject("([1])"));
110 T.CheckCall(T.Val("Object"), T.NewObject("({})"));
111 T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)"));
112 T.CheckCall(T.null(), T.undefined());
113 T.CheckCall(T.null(), T.null());
114 T.CheckCall(T.null(), T.Val("x"));
115 T.CheckCall(T.null(), T.Val(1));
116 }
117
118
119 TEST(ObjectEquals) {
120 FunctionTester T("(function(a,b) { return %_ObjectEquals(a,b); })");
121 CompileRun("var o = {}");
122
123 T.CheckTrue(T.NewObject("(o)"), T.NewObject("(o)"));
124 T.CheckTrue(T.Val("internal"), T.Val("internal"));
125 T.CheckTrue(T.true_value(), T.true_value());
126 T.CheckFalse(T.true_value(), T.false_value());
127 T.CheckFalse(T.NewObject("({})"), T.NewObject("({})"));
128 T.CheckFalse(T.Val("a"), T.Val("b"));
129 }
130
131
132 TEST(ValueOf) {
133 FunctionTester T("(function(a) { return %_ValueOf(a); })");
134
135 T.CheckCall(T.Val("a"), T.Val("a"));
136 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))"));
137 T.CheckCall(T.Val(123), T.Val(123));
138 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))"));
139 }
140
141
142 TEST(SetValueOf) {
143 FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })");
144
145 T.CheckCall(T.Val("a"), T.NewObject("(new String)"), T.Val("a"));
146 T.CheckCall(T.Val(123), T.NewObject("(new Number)"), T.Val(123));
147 T.CheckCall(T.Val("x"), T.undefined(), T.Val("x"));
148 }
149
150
151 TEST(StringCharFromCode) {
152 FunctionTester T("(function(a) { return %_StringCharFromCode(a); })");
153
154 T.CheckCall(T.Val("a"), T.Val(97));
155 T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A));
156 T.CheckCall(T.Val(""), T.undefined());
157 }
158
159
160 TEST(StringCharAt) {
161 FunctionTester T("(function(a,b) { return %_StringCharAt(a,b); })");
162
163 T.CheckCall(T.Val("e"), T.Val("huge fan!"), T.Val(3));
164 T.CheckCall(T.Val("f"), T.Val("\xE2\x9D\x8A fan!"), T.Val(2));
165 T.CheckCall(T.Val(""), T.Val("not a fan!"), T.Val(23));
166 }
167
168
169 TEST(StringCharCodeAt) {
170 FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })");
171
172 T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3));
173 T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2));
174 T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23));
175 }
176
177
178 TEST(StringAdd) {
179 FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })");
180
181 T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb"));
182 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(""));
183 T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb"));
184 }
185
186
187 TEST(StringSubString) {
188 FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })");
189
190 T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0));
191 T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2));
192 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0));
193 }
194
195
196 TEST(StringCompare) {
197 FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })");
198
199 T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb"));
200 T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb"));
201 T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb"));
202 }
203
204
205 TEST(CallFunction) {
206 FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })");
207 CompileRun("function f(a,b,c) { return a + b + c + this.d; }");
208
209 T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f"));
210 T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f"));
211 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-deopt.cc ('k') | test/cctest/compiler/test-run-jsbranches.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698