OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4219 "}\n" | 4219 "}\n" |
4220 "\"PASS\"", | 4220 "\"PASS\"", |
4221 "PASS"); | 4221 "PASS"); |
4222 } | 4222 } |
4223 | 4223 |
4224 | 4224 |
4225 template <typename T> static void USE(T) { } | 4225 template <typename T> static void USE(T) { } |
4226 | 4226 |
4227 | 4227 |
4228 // This test is not intended to be run, just type checked. | 4228 // This test is not intended to be run, just type checked. |
4229 static void PersistentHandles() { | 4229 static inline void PersistentHandles() { |
4230 USE(PersistentHandles); | 4230 USE(PersistentHandles); |
4231 Local<String> str = v8_str("foo"); | 4231 Local<String> str = v8_str("foo"); |
4232 v8::Persistent<String> p_str = v8::Persistent<String>::New(str); | 4232 v8::Persistent<String> p_str = v8::Persistent<String>::New(str); |
4233 USE(p_str); | 4233 USE(p_str); |
4234 Local<Script> scr = Script::Compile(v8_str("")); | 4234 Local<Script> scr = Script::Compile(v8_str("")); |
4235 v8::Persistent<Script> p_scr = v8::Persistent<Script>::New(scr); | 4235 v8::Persistent<Script> p_scr = v8::Persistent<Script>::New(scr); |
4236 USE(p_scr); | 4236 USE(p_scr); |
4237 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4237 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4238 v8::Persistent<ObjectTemplate> p_templ = | 4238 v8::Persistent<ObjectTemplate> p_templ = |
4239 v8::Persistent<ObjectTemplate>::New(templ); | 4239 v8::Persistent<ObjectTemplate>::New(templ); |
(...skipping 7546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11786 CHECK_EQ(28, result->Int32Value()); | 11786 CHECK_EQ(28, result->Int32Value()); |
11787 | 11787 |
11788 result = CompileRun("var sum = 0;" | 11788 result = CompileRun("var sum = 0;" |
11789 "for (var i = 0; i < 8; i++) {" | 11789 "for (var i = 0; i < 8; i++) {" |
11790 " sum += pixels[i];" | 11790 " sum += pixels[i];" |
11791 "}" | 11791 "}" |
11792 "sum;"); | 11792 "sum;"); |
11793 CHECK_EQ(28, result->Int32Value()); | 11793 CHECK_EQ(28, result->Int32Value()); |
11794 | 11794 |
11795 i::Handle<i::Smi> value(i::Smi::FromInt(2)); | 11795 i::Handle<i::Smi> value(i::Smi::FromInt(2)); |
11796 i::SetElement(jsobj, 1, value, i::kNonStrictMode); | 11796 i::Handle<i::Object> no_failure; |
| 11797 no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); |
| 11798 ASSERT(!no_failure.is_null()); |
| 11799 i::USE(no_failure); |
11797 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); | 11800 CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); |
11798 *value.location() = i::Smi::FromInt(256); | 11801 *value.location() = i::Smi::FromInt(256); |
11799 i::SetElement(jsobj, 1, value, i::kNonStrictMode); | 11802 no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); |
| 11803 ASSERT(!no_failure.is_null()); |
| 11804 i::USE(no_failure); |
11800 CHECK_EQ(255, | 11805 CHECK_EQ(255, |
11801 i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); | 11806 i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); |
11802 *value.location() = i::Smi::FromInt(-1); | 11807 *value.location() = i::Smi::FromInt(-1); |
11803 i::SetElement(jsobj, 1, value, i::kNonStrictMode); | 11808 no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); |
| 11809 ASSERT(!no_failure.is_null()); |
| 11810 i::USE(no_failure); |
11804 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); | 11811 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); |
11805 | 11812 |
11806 result = CompileRun("for (var i = 0; i < 8; i++) {" | 11813 result = CompileRun("for (var i = 0; i < 8; i++) {" |
11807 " pixels[i] = (i * 65) - 109;" | 11814 " pixels[i] = (i * 65) - 109;" |
11808 "}" | 11815 "}" |
11809 "pixels[1] + pixels[6];"); | 11816 "pixels[1] + pixels[6];"); |
11810 CHECK_EQ(255, result->Int32Value()); | 11817 CHECK_EQ(255, result->Int32Value()); |
11811 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(0)->ToObjectChecked())->value()); | 11818 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(0)->ToObjectChecked())->value()); |
11812 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); | 11819 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); |
11813 CHECK_EQ(21, | 11820 CHECK_EQ(21, |
(...skipping 3326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15140 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15147 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
15141 | 15148 |
15142 // TODO(1547): Make the following also return "i". | 15149 // TODO(1547): Make the following also return "i". |
15143 // Calling with environment record as base. | 15150 // Calling with environment record as base. |
15144 TestReceiver(o, context->Global(), "func()"); | 15151 TestReceiver(o, context->Global(), "func()"); |
15145 // Calling with no base. | 15152 // Calling with no base. |
15146 TestReceiver(o, context->Global(), "(1,func)()"); | 15153 TestReceiver(o, context->Global(), "(1,func)()"); |
15147 | 15154 |
15148 foreign_context.Dispose(); | 15155 foreign_context.Dispose(); |
15149 } | 15156 } |
OLD | NEW |