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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 class RegisterThreadedTest { | 154 class RegisterThreadedTest { |
155 public: | 155 public: |
156 explicit RegisterThreadedTest(CcTest::TestFunction* callback) | 156 explicit RegisterThreadedTest(CcTest::TestFunction* callback) |
157 : fuzzer_(NULL), callback_(callback) { | 157 : fuzzer_(NULL), callback_(callback) { |
158 prev_ = first_; | 158 prev_ = first_; |
159 first_ = this; | 159 first_ = this; |
160 count_++; | 160 count_++; |
161 } | 161 } |
162 static int count() { return count_; } | 162 static int count() { return count_; } |
163 static RegisterThreadedTest* nth(int i) { | 163 static RegisterThreadedTest* nth(int i) { |
164 ASSERT(i < count()); | 164 CHECK(i < count()); |
165 RegisterThreadedTest* current = first_; | 165 RegisterThreadedTest* current = first_; |
166 while (i > 0) { | 166 while (i > 0) { |
167 i--; | 167 i--; |
168 current = current->prev_; | 168 current = current->prev_; |
169 } | 169 } |
170 return current; | 170 return current; |
171 } | 171 } |
172 CcTest::TestFunction* callback() { return callback_; } | 172 CcTest::TestFunction* callback() { return callback_; } |
173 ApiTestFuzzer* fuzzer_; | 173 ApiTestFuzzer* fuzzer_; |
174 | 174 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); | 288 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); |
289 cons->SetClassName(v8_str("Cons")); | 289 cons->SetClassName(v8_str("Cons")); |
290 v8::Handle<v8::Signature> sig = | 290 v8::Handle<v8::Signature> sig = |
291 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 1, &cons); | 291 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 1, &cons); |
292 v8::Handle<v8::FunctionTemplate> fun = | 292 v8::Handle<v8::FunctionTemplate> fun = |
293 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig); | 293 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig); |
294 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); | 294 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); |
295 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); | 295 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); |
296 | 296 |
297 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); | 297 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); |
298 ASSERT(value1->IsTrue()); | 298 CHECK(value1->IsTrue()); |
299 | 299 |
300 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); | 300 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); |
301 ASSERT(value2->IsTrue()); | 301 CHECK(value2->IsTrue()); |
302 | 302 |
303 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); | 303 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); |
304 ASSERT(value3->IsTrue()); | 304 CHECK(value3->IsTrue()); |
305 | 305 |
306 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(); | 306 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(); |
307 cons1->SetClassName(v8_str("Cons1")); | 307 cons1->SetClassName(v8_str("Cons1")); |
308 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(); | 308 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(); |
309 cons2->SetClassName(v8_str("Cons2")); | 309 cons2->SetClassName(v8_str("Cons2")); |
310 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(); | 310 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(); |
311 cons3->SetClassName(v8_str("Cons3")); | 311 cons3->SetClassName(v8_str("Cons3")); |
312 | 312 |
313 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; | 313 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; |
314 v8::Handle<v8::Signature> wsig = | 314 v8::Handle<v8::Signature> wsig = |
315 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 3, args); | 315 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 3, args); |
316 v8::Handle<v8::FunctionTemplate> fun2 = | 316 v8::Handle<v8::FunctionTemplate> fun2 = |
317 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig); | 317 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig); |
318 | 318 |
319 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); | 319 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); |
320 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); | 320 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); |
321 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); | 321 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); |
322 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); | 322 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); |
323 v8::Handle<Value> value4 = CompileRun( | 323 v8::Handle<Value> value4 = CompileRun( |
324 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" | 324 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" |
325 "'[object Cons1],[object Cons2],[object Cons3]'"); | 325 "'[object Cons1],[object Cons2],[object Cons3]'"); |
326 ASSERT(value4->IsTrue()); | 326 CHECK(value4->IsTrue()); |
327 | 327 |
328 v8::Handle<Value> value5 = CompileRun( | 328 v8::Handle<Value> value5 = CompileRun( |
329 "Fun2(new Cons1(), new Cons2(), 5) == '[object Cons1],[object Cons2],'"); | 329 "Fun2(new Cons1(), new Cons2(), 5) == '[object Cons1],[object Cons2],'"); |
330 ASSERT(value5->IsTrue()); | 330 CHECK(value5->IsTrue()); |
331 | 331 |
332 v8::Handle<Value> value6 = CompileRun( | 332 v8::Handle<Value> value6 = CompileRun( |
333 "Fun2(new Cons3(), new Cons2(), new Cons1()) == ',[object Cons2],'"); | 333 "Fun2(new Cons3(), new Cons2(), new Cons1()) == ',[object Cons2],'"); |
334 ASSERT(value6->IsTrue()); | 334 CHECK(value6->IsTrue()); |
335 | 335 |
336 v8::Handle<Value> value7 = CompileRun( | 336 v8::Handle<Value> value7 = CompileRun( |
337 "Fun2(new Cons1(), new Cons2(), new Cons3(), 'd') == " | 337 "Fun2(new Cons1(), new Cons2(), new Cons3(), 'd') == " |
338 "'[object Cons1],[object Cons2],[object Cons3],d';"); | 338 "'[object Cons1],[object Cons2],[object Cons3],d';"); |
339 ASSERT(value7->IsTrue()); | 339 CHECK(value7->IsTrue()); |
340 | 340 |
341 v8::Handle<Value> value8 = CompileRun( | 341 v8::Handle<Value> value8 = CompileRun( |
342 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'"); | 342 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'"); |
343 ASSERT(value8->IsTrue()); | 343 CHECK(value8->IsTrue()); |
344 } | 344 } |
345 | 345 |
346 | 346 |
347 THREADED_TEST(HulIgennem) { | 347 THREADED_TEST(HulIgennem) { |
348 v8::HandleScope scope; | 348 v8::HandleScope scope; |
349 LocalContext env; | 349 LocalContext env; |
350 v8::Handle<v8::Primitive> undef = v8::Undefined(); | 350 v8::Handle<v8::Primitive> undef = v8::Undefined(); |
351 Local<String> undef_str = undef->ToString(); | 351 Local<String> undef_str = undef->ToString(); |
352 char* value = i::NewArray<char>(undef_str->Length() + 1); | 352 char* value = i::NewArray<char>(undef_str->Length() + 1); |
353 undef_str->WriteAscii(value); | 353 undef_str->WriteAscii(value); |
(...skipping 6098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6452 // the property | 6452 // the property |
6453 pass_on_get = false; | 6453 pass_on_get = false; |
6454 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 6454 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
6455 CHECK_EQ(1, force_set_set_count); | 6455 CHECK_EQ(1, force_set_set_count); |
6456 CHECK_EQ(5, force_set_get_count); | 6456 CHECK_EQ(5, force_set_get_count); |
6457 // The interceptor should also work for other properties | 6457 // The interceptor should also work for other properties |
6458 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); | 6458 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); |
6459 CHECK_EQ(1, force_set_set_count); | 6459 CHECK_EQ(1, force_set_set_count); |
6460 CHECK_EQ(6, force_set_get_count); | 6460 CHECK_EQ(6, force_set_get_count); |
6461 } | 6461 } |
OLD | NEW |