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

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

Issue 248033: Return the original value when assigning to a pixel array (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/ia32/ic-ia32.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 7711 matching lines...) Expand 10 before | Expand all | Expand 10 after
7722 // Set the elements to be the pixels. 7722 // Set the elements to be the pixels.
7723 // jsobj->set_elements(*pixels); 7723 // jsobj->set_elements(*pixels);
7724 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); 7724 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount);
7725 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value()); 7725 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value());
7726 obj->Set(v8_str("field"), v8::Int32::New(1503)); 7726 obj->Set(v8_str("field"), v8::Int32::New(1503));
7727 context->Global()->Set(v8_str("pixels"), obj); 7727 context->Global()->Set(v8_str("pixels"), obj);
7728 v8::Handle<v8::Value> result = CompileRun("pixels.field"); 7728 v8::Handle<v8::Value> result = CompileRun("pixels.field");
7729 CHECK_EQ(1503, result->Int32Value()); 7729 CHECK_EQ(1503, result->Int32Value());
7730 result = CompileRun("pixels[1]"); 7730 result = CompileRun("pixels[1]");
7731 CHECK_EQ(1, result->Int32Value()); 7731 CHECK_EQ(1, result->Int32Value());
7732
7733 result = CompileRun("var sum = 0;"
7734 "for (var i = 0; i < 8; i++) {"
7735 " sum += pixels[i] = pixels[i] = -i;"
7736 "}"
7737 "sum;");
7738 CHECK_EQ(-28, result->Int32Value());
7739
7740 result = CompileRun("var sum = 0;"
7741 "for (var i = 0; i < 8; i++) {"
7742 " sum += pixels[i] = pixels[i] = 0;"
7743 "}"
7744 "sum;");
7745 CHECK_EQ(0, result->Int32Value());
7746
7747 result = CompileRun("var sum = 0;"
7748 "for (var i = 0; i < 8; i++) {"
7749 " sum += pixels[i] = pixels[i] = 255;"
7750 "}"
7751 "sum;");
7752 CHECK_EQ(8 * 255, result->Int32Value());
7753
7754 result = CompileRun("var sum = 0;"
7755 "for (var i = 0; i < 8; i++) {"
7756 " sum += pixels[i] = pixels[i] = 256 + i;"
7757 "}"
7758 "sum;");
7759 CHECK_EQ(2076, result->Int32Value());
7760
7761 result = CompileRun("var sum = 0;"
7762 "for (var i = 0; i < 8; i++) {"
7763 " sum += pixels[i] = pixels[i] = i;"
7764 "}"
7765 "sum;");
7766 CHECK_EQ(28, result->Int32Value());
7767
7732 result = CompileRun("var sum = 0;" 7768 result = CompileRun("var sum = 0;"
7733 "for (var i = 0; i < 8; i++) {" 7769 "for (var i = 0; i < 8; i++) {"
7734 " sum += pixels[i];" 7770 " sum += pixels[i];"
7735 "}" 7771 "}"
7736 "sum;"); 7772 "sum;");
7737 CHECK_EQ(28, result->Int32Value()); 7773 CHECK_EQ(28, result->Int32Value());
7738 7774
7739 i::Handle<i::Smi> value(i::Smi::FromInt(2)); 7775 i::Handle<i::Smi> value(i::Smi::FromInt(2));
7740 i::SetElement(jsobj, 1, value); 7776 i::SetElement(jsobj, 1, value);
7741 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1))->value()); 7777 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1))->value());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
7832 "js_array;"); 7868 "js_array;");
7833 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 7869 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
7834 7870
7835 result = CompileRun("pixels[1] = 23;" 7871 result = CompileRun("pixels[1] = 23;"
7836 "pixels.__proto__ = [];" 7872 "pixels.__proto__ = [];"
7837 "js_array.__proto__ = pixels;" 7873 "js_array.__proto__ = pixels;"
7838 "js_array.concat(pixels);"); 7874 "js_array.concat(pixels);");
7839 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 7875 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
7840 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); 7876 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
7841 7877
7878 result = CompileRun("pixels[1] = 23;");
7879 CHECK_EQ(23, result->Int32Value());
7880
7842 free(pixel_data); 7881 free(pixel_data);
7843 } 7882 }
7844 7883
7845 7884
7846 THREADED_TEST(ScriptContextDependence) { 7885 THREADED_TEST(ScriptContextDependence) {
7847 v8::HandleScope scope; 7886 v8::HandleScope scope;
7848 LocalContext c1; 7887 LocalContext c1;
7849 const char *source = "foo"; 7888 const char *source = "foo";
7850 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); 7889 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source));
7851 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); 7890 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source));
(...skipping 20 matching lines...) Expand all
7872 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); 7911 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL);
7873 } 7912 }
7874 7913
7875 7914
7876 // Test that idle notification can be handled when V8 has not yet been 7915 // Test that idle notification can be handled when V8 has not yet been
7877 // set up. 7916 // set up.
7878 THREADED_TEST(IdleNotification) { 7917 THREADED_TEST(IdleNotification) {
7879 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true); 7918 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(true);
7880 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false); 7919 for (int i = 0; i < 100; i++) v8::V8::IdleNotification(false);
7881 } 7920 }
OLDNEW
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698