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

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

Issue 255021: Merge bleeding_edge revision 2961 to branches/1.2 (Closed) Base URL: http://v8.googlecode.com/svn/branches/1.2/
Patch Set: Created 11 years, 2 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/version.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 7196 matching lines...) Expand 10 before | Expand all | Expand 10 after
7207 // Set the elements to be the pixels. 7207 // Set the elements to be the pixels.
7208 // jsobj->set_elements(*pixels); 7208 // jsobj->set_elements(*pixels);
7209 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); 7209 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount);
7210 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value()); 7210 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value());
7211 obj->Set(v8_str("field"), v8::Int32::New(1503)); 7211 obj->Set(v8_str("field"), v8::Int32::New(1503));
7212 context->Global()->Set(v8_str("pixels"), obj); 7212 context->Global()->Set(v8_str("pixels"), obj);
7213 v8::Handle<v8::Value> result = CompileRun("pixels.field"); 7213 v8::Handle<v8::Value> result = CompileRun("pixels.field");
7214 CHECK_EQ(1503, result->Int32Value()); 7214 CHECK_EQ(1503, result->Int32Value());
7215 result = CompileRun("pixels[1]"); 7215 result = CompileRun("pixels[1]");
7216 CHECK_EQ(1, result->Int32Value()); 7216 CHECK_EQ(1, result->Int32Value());
7217
7218 result = CompileRun("var sum = 0;"
7219 "for (var i = 0; i < 8; i++) {"
7220 " sum += pixels[i] = pixels[i] = -i;"
7221 "}"
7222 "sum;");
7223 CHECK_EQ(-28, result->Int32Value());
7224
7225 result = CompileRun("var sum = 0;"
7226 "for (var i = 0; i < 8; i++) {"
7227 " sum += pixels[i] = pixels[i] = 0;"
7228 "}"
7229 "sum;");
7230 CHECK_EQ(0, result->Int32Value());
7231
7232 result = CompileRun("var sum = 0;"
7233 "for (var i = 0; i < 8; i++) {"
7234 " sum += pixels[i] = pixels[i] = 255;"
7235 "}"
7236 "sum;");
7237 CHECK_EQ(8 * 255, result->Int32Value());
7238
7239 result = CompileRun("var sum = 0;"
7240 "for (var i = 0; i < 8; i++) {"
7241 " sum += pixels[i] = pixels[i] = 256 + i;"
7242 "}"
7243 "sum;");
7244 CHECK_EQ(2076, result->Int32Value());
7245
7246 result = CompileRun("var sum = 0;"
7247 "for (var i = 0; i < 8; i++) {"
7248 " sum += pixels[i] = pixels[i] = i;"
7249 "}"
7250 "sum;");
7251 CHECK_EQ(28, result->Int32Value());
7252
7217 result = CompileRun("var sum = 0;" 7253 result = CompileRun("var sum = 0;"
7218 "for (var i = 0; i < 8; i++) {" 7254 "for (var i = 0; i < 8; i++) {"
7219 " sum += pixels[i];" 7255 " sum += pixels[i];"
7220 "}" 7256 "}"
7221 "sum;"); 7257 "sum;");
7222 CHECK_EQ(28, result->Int32Value()); 7258 CHECK_EQ(28, result->Int32Value());
7223 7259
7224 i::Handle<i::Smi> value(i::Smi::FromInt(2)); 7260 i::Handle<i::Smi> value(i::Smi::FromInt(2));
7225 i::SetElement(jsobj, 1, value); 7261 i::SetElement(jsobj, 1, value);
7226 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1))->value()); 7262 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1))->value());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
7317 "js_array;"); 7353 "js_array;");
7318 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 7354 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
7319 7355
7320 result = CompileRun("pixels[1] = 23;" 7356 result = CompileRun("pixels[1] = 23;"
7321 "pixels.__proto__ = [];" 7357 "pixels.__proto__ = [];"
7322 "js_array.__proto__ = pixels;" 7358 "js_array.__proto__ = pixels;"
7323 "js_array.concat(pixels);"); 7359 "js_array.concat(pixels);");
7324 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 7360 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
7325 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); 7361 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
7326 7362
7363 result = CompileRun("pixels[1] = 23;");
7364 CHECK_EQ(23, result->Int32Value());
7365
7327 free(pixel_data); 7366 free(pixel_data);
7328 } 7367 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698