OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "test/cctest/compiler/code-assembler-tester.h" | 10 #include "test/cctest/compiler/code-assembler-tester.h" |
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 Handle<PromiseReactionJobInfo> promise_info = | 2096 Handle<PromiseReactionJobInfo> promise_info = |
2097 Handle<PromiseReactionJobInfo>::cast(result); | 2097 Handle<PromiseReactionJobInfo>::cast(result); |
2098 CHECK_EQ(Smi::FromInt(1), promise_info->value()); | 2098 CHECK_EQ(Smi::FromInt(1), promise_info->value()); |
2099 CHECK(promise_info->tasks()->IsFixedArray()); | 2099 CHECK(promise_info->tasks()->IsFixedArray()); |
2100 CHECK(promise_info->deferred()->IsFixedArray()); | 2100 CHECK(promise_info->deferred()->IsFixedArray()); |
2101 CHECK(promise_info->context()->IsContext()); | 2101 CHECK(promise_info->context()->IsContext()); |
2102 CHECK(promise_info->debug_id()->IsUndefined(isolate)); | 2102 CHECK(promise_info->debug_id()->IsUndefined(isolate)); |
2103 CHECK(promise_info->debug_name()->IsUndefined(isolate)); | 2103 CHECK(promise_info->debug_name()->IsUndefined(isolate)); |
2104 } | 2104 } |
2105 | 2105 |
| 2106 TEST(IsSymbol) { |
| 2107 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 2108 |
| 2109 const int kNumParams = 1; |
| 2110 CodeAssemblerTester data(isolate, kNumParams); |
| 2111 CodeStubAssembler m(data.state()); |
| 2112 |
| 2113 Node* const symbol = m.Parameter(0); |
| 2114 m.Return(m.SelectBooleanConstant(m.IsSymbol(symbol))); |
| 2115 |
| 2116 Handle<Code> code = data.GenerateCode(); |
| 2117 CHECK(!code.is_null()); |
| 2118 |
| 2119 FunctionTester ft(code, kNumParams); |
| 2120 Handle<Object> result = |
| 2121 ft.Call(isolate->factory()->NewSymbol()).ToHandleChecked(); |
| 2122 CHECK_EQ(isolate->heap()->true_value(), *result); |
| 2123 |
| 2124 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked(); |
| 2125 CHECK_EQ(isolate->heap()->false_value(), *result); |
| 2126 } |
| 2127 |
| 2128 TEST(IsPrivateSymbol) { |
| 2129 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 2130 |
| 2131 const int kNumParams = 1; |
| 2132 CodeAssemblerTester data(isolate, kNumParams); |
| 2133 CodeStubAssembler m(data.state()); |
| 2134 |
| 2135 Node* const symbol = m.Parameter(0); |
| 2136 m.Return(m.SelectBooleanConstant(m.IsPrivateSymbol(symbol))); |
| 2137 |
| 2138 Handle<Code> code = data.GenerateCode(); |
| 2139 CHECK(!code.is_null()); |
| 2140 |
| 2141 FunctionTester ft(code, kNumParams); |
| 2142 Handle<Object> result = |
| 2143 ft.Call(isolate->factory()->NewSymbol()).ToHandleChecked(); |
| 2144 CHECK_EQ(isolate->heap()->false_value(), *result); |
| 2145 |
| 2146 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked(); |
| 2147 CHECK_EQ(isolate->heap()->false_value(), *result); |
| 2148 |
| 2149 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked(); |
| 2150 CHECK_EQ(isolate->heap()->true_value(), *result); |
| 2151 } |
| 2152 |
2106 } // namespace internal | 2153 } // namespace internal |
2107 } // namespace v8 | 2154 } // namespace v8 |
OLD | NEW |