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 6493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6504 CHECK(!v8_str("a")->SameValue(v8_str("b"))); | 6504 CHECK(!v8_str("a")->SameValue(v8_str("b"))); |
6505 CHECK(!v8_str("5")->SameValue(v8_num(5))); | 6505 CHECK(!v8_str("5")->SameValue(v8_num(5))); |
6506 CHECK(v8_num(1)->SameValue(v8_num(1))); | 6506 CHECK(v8_num(1)->SameValue(v8_num(1))); |
6507 CHECK(!v8_num(1)->SameValue(v8_num(2))); | 6507 CHECK(!v8_num(1)->SameValue(v8_num(2))); |
6508 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); | 6508 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); |
6509 CHECK(not_a_number->SameValue(not_a_number)); | 6509 CHECK(not_a_number->SameValue(not_a_number)); |
6510 CHECK(v8::False(isolate)->SameValue(v8::False(isolate))); | 6510 CHECK(v8::False(isolate)->SameValue(v8::False(isolate))); |
6511 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate))); | 6511 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate))); |
6512 } | 6512 } |
6513 | 6513 |
| 6514 THREADED_TEST(TypeOf) { |
| 6515 LocalContext context; |
| 6516 v8::Isolate* isolate = context->GetIsolate(); |
| 6517 v8::HandleScope scope(context->GetIsolate()); |
| 6518 |
| 6519 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 6520 Local<v8::Function> fun = t1->GetFunction(context.local()).ToLocalChecked(); |
| 6521 |
| 6522 CHECK(v8::Undefined(isolate) |
| 6523 ->TypeOf(context.local()) |
| 6524 .ToLocalChecked() |
| 6525 ->Equals(context.local(), v8_str("undefined")) |
| 6526 .FromJust()); |
| 6527 CHECK(v8::Null(isolate) |
| 6528 ->TypeOf(context.local()) |
| 6529 .ToLocalChecked() |
| 6530 ->Equals(context.local(), v8_str("object")) |
| 6531 .FromJust()); |
| 6532 CHECK(v8_str("str") |
| 6533 ->TypeOf(context.local()) |
| 6534 .ToLocalChecked() |
| 6535 ->Equals(context.local(), v8_str("string")) |
| 6536 .FromJust()); |
| 6537 CHECK(v8_num(0.0) |
| 6538 ->TypeOf(context.local()) |
| 6539 .ToLocalChecked() |
| 6540 ->Equals(context.local(), v8_str("number")) |
| 6541 .FromJust()); |
| 6542 CHECK(v8_num(1) |
| 6543 ->TypeOf(context.local()) |
| 6544 .ToLocalChecked() |
| 6545 ->Equals(context.local(), v8_str("number")) |
| 6546 .FromJust()); |
| 6547 CHECK(v8::Object::New(isolate) |
| 6548 ->TypeOf(context.local()) |
| 6549 .ToLocalChecked() |
| 6550 ->Equals(context.local(), v8_str("object")) |
| 6551 .FromJust()); |
| 6552 CHECK(v8::Boolean::New(isolate, true) |
| 6553 ->TypeOf(context.local()) |
| 6554 .ToLocalChecked() |
| 6555 ->Equals(context.local(), v8_str("boolean")) |
| 6556 .FromJust()); |
| 6557 CHECK(fun->TypeOf(context.local()) |
| 6558 .ToLocalChecked() |
| 6559 ->Equals(context.local(), v8_str("function")) |
| 6560 .FromJust()); |
| 6561 } |
6514 | 6562 |
6515 THREADED_TEST(MultiRun) { | 6563 THREADED_TEST(MultiRun) { |
6516 LocalContext context; | 6564 LocalContext context; |
6517 v8::HandleScope scope(context->GetIsolate()); | 6565 v8::HandleScope scope(context->GetIsolate()); |
6518 Local<Script> script = v8_compile("x"); | 6566 Local<Script> script = v8_compile("x"); |
6519 for (int i = 0; i < 10; i++) { | 6567 for (int i = 0; i < 10; i++) { |
6520 script->Run(context.local()).IsEmpty(); | 6568 script->Run(context.local()).IsEmpty(); |
6521 } | 6569 } |
6522 } | 6570 } |
6523 | 6571 |
(...skipping 18325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24849 CHECK(proxy->GetTarget()->SameValue(target)); | 24897 CHECK(proxy->GetTarget()->SameValue(target)); |
24850 CHECK(proxy->GetHandler()->SameValue(handler)); | 24898 CHECK(proxy->GetHandler()->SameValue(handler)); |
24851 | 24899 |
24852 proxy->Revoke(); | 24900 proxy->Revoke(); |
24853 CHECK(proxy->IsProxy()); | 24901 CHECK(proxy->IsProxy()); |
24854 CHECK(!target->IsProxy()); | 24902 CHECK(!target->IsProxy()); |
24855 CHECK(proxy->IsRevoked()); | 24903 CHECK(proxy->IsRevoked()); |
24856 CHECK(proxy->GetTarget()->SameValue(target)); | 24904 CHECK(proxy->GetTarget()->SameValue(target)); |
24857 CHECK(proxy->GetHandler()->IsNull()); | 24905 CHECK(proxy->GetHandler()->IsNull()); |
24858 } | 24906 } |
OLD | NEW |