| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |