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::Value::TypeOf(context.local(), v8::Undefined(isolate)) |
| 6523 .ToLocalChecked() |
| 6524 ->Equals(context.local(), v8_str("undefined")) |
| 6525 .FromJust()); |
| 6526 CHECK(v8::Value::TypeOf(context.local(), v8::Null(isolate)) |
| 6527 .ToLocalChecked() |
| 6528 ->Equals(context.local(), v8_str("object")) |
| 6529 .FromJust()); |
| 6530 CHECK(v8::Value::TypeOf(context.local(), v8_str("str")) |
| 6531 .ToLocalChecked() |
| 6532 ->Equals(context.local(), v8_str("string")) |
| 6533 .FromJust()); |
| 6534 CHECK(v8::Value::TypeOf(context.local(), v8_num(0.0)) |
| 6535 .ToLocalChecked() |
| 6536 ->Equals(context.local(), v8_str("number")) |
| 6537 .FromJust()); |
| 6538 CHECK(v8::Value::TypeOf(context.local(), v8_num(1)) |
| 6539 .ToLocalChecked() |
| 6540 ->Equals(context.local(), v8_str("number")) |
| 6541 .FromJust()); |
| 6542 CHECK(v8::Value::TypeOf(context.local(), v8::Object::New(isolate)) |
| 6543 .ToLocalChecked() |
| 6544 ->Equals(context.local(), v8_str("object")) |
| 6545 .FromJust()); |
| 6546 CHECK(v8::Value::TypeOf(context.local(), v8::Boolean::New(isolate, true)) |
| 6547 .ToLocalChecked() |
| 6548 ->Equals(context.local(), v8_str("boolean")) |
| 6549 .FromJust()); |
| 6550 CHECK(v8::Value::TypeOf(context.local(), fun) |
| 6551 .ToLocalChecked() |
| 6552 ->Equals(context.local(), v8_str("function")) |
| 6553 .FromJust()); |
| 6554 } |
6514 | 6555 |
6515 THREADED_TEST(MultiRun) { | 6556 THREADED_TEST(MultiRun) { |
6516 LocalContext context; | 6557 LocalContext context; |
6517 v8::HandleScope scope(context->GetIsolate()); | 6558 v8::HandleScope scope(context->GetIsolate()); |
6518 Local<Script> script = v8_compile("x"); | 6559 Local<Script> script = v8_compile("x"); |
6519 for (int i = 0; i < 10; i++) { | 6560 for (int i = 0; i < 10; i++) { |
6520 script->Run(context.local()).IsEmpty(); | 6561 script->Run(context.local()).IsEmpty(); |
6521 } | 6562 } |
6522 } | 6563 } |
6523 | 6564 |
(...skipping 18325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24849 CHECK(proxy->GetTarget()->SameValue(target)); | 24890 CHECK(proxy->GetTarget()->SameValue(target)); |
24850 CHECK(proxy->GetHandler()->SameValue(handler)); | 24891 CHECK(proxy->GetHandler()->SameValue(handler)); |
24851 | 24892 |
24852 proxy->Revoke(); | 24893 proxy->Revoke(); |
24853 CHECK(proxy->IsProxy()); | 24894 CHECK(proxy->IsProxy()); |
24854 CHECK(!target->IsProxy()); | 24895 CHECK(!target->IsProxy()); |
24855 CHECK(proxy->IsRevoked()); | 24896 CHECK(proxy->IsRevoked()); |
24856 CHECK(proxy->GetTarget()->SameValue(target)); | 24897 CHECK(proxy->GetTarget()->SameValue(target)); |
24857 CHECK(proxy->GetHandler()->IsNull()); | 24898 CHECK(proxy->GetHandler()->IsNull()); |
24858 } | 24899 } |
OLD | NEW |