OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 16161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16172 " try {" | 16172 " try {" |
16173 " return readCell();" | 16173 " return readCell();" |
16174 " } catch(e) {" | 16174 " } catch(e) {" |
16175 " return e.toString();" | 16175 " return e.toString();" |
16176 " }" | 16176 " }" |
16177 "})()", | 16177 "})()", |
16178 "ReferenceError: cell is not defined"); | 16178 "ReferenceError: cell is not defined"); |
16179 } | 16179 } |
16180 | 16180 |
16181 | 16181 |
| 16182 class Visitor42 : public v8::PersistentHandleVisitor { |
| 16183 public: |
| 16184 explicit Visitor42(v8::Persistent<v8::Object> object) |
| 16185 : counter_(0), object_(object) { } |
| 16186 |
| 16187 virtual void VisitPersistentHandle(Persistent<Value> value, |
| 16188 uint16_t class_id) { |
| 16189 if (class_id == 42) { |
| 16190 CHECK(value->IsObject()); |
| 16191 v8::Persistent<v8::Object> visited = |
| 16192 v8::Persistent<v8::Object>::Cast(value); |
| 16193 CHECK_EQ(42, visited.WrapperClassId()); |
| 16194 CHECK_EQ(object_, visited); |
| 16195 ++counter_; |
| 16196 } |
| 16197 } |
| 16198 |
| 16199 int counter_; |
| 16200 v8::Persistent<v8::Object> object_; |
| 16201 }; |
| 16202 |
| 16203 |
16182 TEST(PersistentHandleVisitor) { | 16204 TEST(PersistentHandleVisitor) { |
16183 v8::HandleScope scope; | 16205 v8::HandleScope scope; |
16184 LocalContext context; | 16206 LocalContext context; |
16185 v8::Persistent<v8::Object> object = | 16207 v8::Persistent<v8::Object> object = |
16186 v8::Persistent<v8::Object>::New(v8::Object::New()); | 16208 v8::Persistent<v8::Object>::New(v8::Object::New()); |
16187 CHECK_EQ(0, object.WrapperClassId()); | 16209 CHECK_EQ(0, object.WrapperClassId()); |
16188 object.SetWrapperClassId(42); | 16210 object.SetWrapperClassId(42); |
16189 CHECK_EQ(42, object.WrapperClassId()); | 16211 CHECK_EQ(42, object.WrapperClassId()); |
16190 | 16212 |
16191 class Visitor : public v8::PersistentHandleVisitor { | 16213 Visitor42 visitor(object); |
16192 public: | |
16193 explicit Visitor(v8::Persistent<v8::Object> object) | |
16194 : counter_(0), object_(object) { } | |
16195 | |
16196 virtual void VisitPersistentHandle(Persistent<Value> value, | |
16197 uint16_t class_id) { | |
16198 if (class_id == 42) { | |
16199 CHECK(value->IsObject()); | |
16200 v8::Persistent<v8::Object> visited = | |
16201 v8::Persistent<v8::Object>::Cast(value); | |
16202 CHECK_EQ(42, visited.WrapperClassId()); | |
16203 CHECK_EQ(object_, visited); | |
16204 ++counter_; | |
16205 } | |
16206 } | |
16207 | |
16208 int counter_; | |
16209 v8::Persistent<v8::Object> object_; | |
16210 } visitor(object); | |
16211 | |
16212 v8::V8::VisitHandlesWithClassIds(&visitor); | 16214 v8::V8::VisitHandlesWithClassIds(&visitor); |
16213 CHECK_EQ(1, visitor.counter_); | 16215 CHECK_EQ(1, visitor.counter_); |
16214 | 16216 |
16215 object.Dispose(); | 16217 object.Dispose(); |
16216 } | 16218 } |
16217 | 16219 |
16218 | 16220 |
16219 TEST(RegExp) { | 16221 TEST(RegExp) { |
16220 v8::HandleScope scope; | 16222 v8::HandleScope scope; |
16221 LocalContext context; | 16223 LocalContext context; |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17662 | 17664 |
17663 i::Semaphore* sem_; | 17665 i::Semaphore* sem_; |
17664 volatile int sem_value_; | 17666 volatile int sem_value_; |
17665 }; | 17667 }; |
17666 | 17668 |
17667 | 17669 |
17668 THREADED_TEST(SemaphoreInterruption) { | 17670 THREADED_TEST(SemaphoreInterruption) { |
17669 ThreadInterruptTest().RunTest(); | 17671 ThreadInterruptTest().RunTest(); |
17670 } | 17672 } |
17671 #endif // WIN32 | 17673 #endif // WIN32 |
OLD | NEW |