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 5785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5796 | 5796 |
5797 // Local context should still be live. | 5797 // Local context should still be live. |
5798 CHECK(!local_env.IsEmpty()); | 5798 CHECK(!local_env.IsEmpty()); |
5799 local_env->Enter(); | 5799 local_env->Enter(); |
5800 | 5800 |
5801 // Should complete without problems. | 5801 // Should complete without problems. |
5802 RegExpInterruptTest().RunTest(); | 5802 RegExpInterruptTest().RunTest(); |
5803 | 5803 |
5804 local_env->Exit(); | 5804 local_env->Exit(); |
5805 } | 5805 } |
| 5806 |
| 5807 |
| 5808 // Verify that we can clone an object |
| 5809 TEST(ObjectClone) { |
| 5810 v8::HandleScope scope; |
| 5811 LocalContext env; |
| 5812 |
| 5813 char* sample = |
| 5814 "var rv = {};" \ |
| 5815 "rv.alpha = 'hello';" \ |
| 5816 "rv.beta = 123;" \ |
| 5817 "rv;"; |
| 5818 |
| 5819 // Create an object, verify basics. |
| 5820 Local<Value> val = CompileRun(sample); |
| 5821 CHECK(val->IsObject()); |
| 5822 Local<v8::Object> obj = Local<v8::Object>::Cast(val); |
| 5823 obj->Set(v8_str("gamma"), v8_str("cloneme")); |
| 5824 |
| 5825 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); |
| 5826 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); |
| 5827 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); |
| 5828 |
| 5829 // Clone it. |
| 5830 Local<v8::Object> clone = obj->Clone(); |
| 5831 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
| 5832 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); |
| 5833 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
| 5834 |
| 5835 // Set a property on the clone, verify each object. |
| 5836 clone->Set(v8_str("beta"), v8::Integer::New(456)); |
| 5837 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); |
| 5838 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); |
| 5839 } |
| 5840 |
OLD | NEW |