OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 9722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9733 } | 9733 } |
9734 | 9734 |
9735 | 9735 |
9736 static void SetterWhichSetsYOnThisTo23(Local<String> name, | 9736 static void SetterWhichSetsYOnThisTo23(Local<String> name, |
9737 Local<Value> value, | 9737 Local<Value> value, |
9738 const AccessorInfo& info) { | 9738 const AccessorInfo& info) { |
9739 info.This()->Set(v8_str("y"), v8_num(23)); | 9739 info.This()->Set(v8_str("y"), v8_num(23)); |
9740 } | 9740 } |
9741 | 9741 |
9742 | 9742 |
9743 THREADED_TEST(SetterOnConstructorPrototype) { | 9743 TEST(SetterOnConstructorPrototype) { |
9744 v8::HandleScope scope; | 9744 v8::HandleScope scope; |
9745 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 9745 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
9746 templ->SetAccessor(v8_str("x"), | 9746 templ->SetAccessor(v8_str("x"), |
9747 GetterWhichReturns42, | 9747 GetterWhichReturns42, |
9748 SetterWhichSetsYOnThisTo23); | 9748 SetterWhichSetsYOnThisTo23); |
9749 LocalContext context; | 9749 LocalContext context; |
9750 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 9750 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
9751 CompileRun("function C1() {" | 9751 CompileRun("function C1() {" |
9752 " this.x = 23;" | 9752 " this.x = 23;" |
9753 "};" | 9753 "};" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9815 CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value()); | 9815 CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value()); |
9816 } | 9816 } |
9817 | 9817 |
9818 script = v8::Script::Compile(v8_str("new C2();")); | 9818 script = v8::Script::Compile(v8_str("new C2();")); |
9819 for (int i = 0; i < 10; i++) { | 9819 for (int i = 0; i < 10; i++) { |
9820 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); | 9820 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); |
9821 CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value()); | 9821 CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value()); |
9822 CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value()); | 9822 CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value()); |
9823 } | 9823 } |
9824 } | 9824 } |
OLD | NEW |