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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 PostInitializeContext(context); | 138 PostInitializeContext(context); |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 void DeclarationContext::Check(const char* source, int get, int set, int query, | 142 void DeclarationContext::Check(const char* source, int get, int set, int query, |
143 Expectations expectations, | 143 Expectations expectations, |
144 v8::Local<Value> value) { | 144 v8::Local<Value> value) { |
145 InitializeIfNeeded(); | 145 InitializeIfNeeded(); |
146 // A retry after a GC may pollute the counts, so perform gc now | 146 // A retry after a GC may pollute the counts, so perform gc now |
147 // to avoid that. | 147 // to avoid that. |
148 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 148 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
149 HandleScope scope(CcTest::isolate()); | 149 HandleScope scope(CcTest::isolate()); |
150 TryCatch catcher(CcTest::isolate()); | 150 TryCatch catcher(CcTest::isolate()); |
151 catcher.SetVerbose(true); | 151 catcher.SetVerbose(true); |
152 Local<Context> context = CcTest::isolate()->GetCurrentContext(); | 152 Local<Context> context = CcTest::isolate()->GetCurrentContext(); |
153 MaybeLocal<Script> script = Script::Compile( | 153 MaybeLocal<Script> script = Script::Compile( |
154 context, | 154 context, |
155 String::NewFromUtf8(CcTest::isolate(), source, v8::NewStringType::kNormal) | 155 String::NewFromUtf8(CcTest::isolate(), source, v8::NewStringType::kNormal) |
156 .ToLocalChecked()); | 156 .ToLocalChecked()); |
157 if (expectations == EXPECT_ERROR) { | 157 if (expectations == EXPECT_ERROR) { |
158 CHECK(script.IsEmpty()); | 158 CHECK(script.IsEmpty()); |
(...skipping 10 matching lines...) Expand all Loading... |
169 CHECK(value->Equals(context, result.ToLocalChecked()).FromJust()); | 169 CHECK(value->Equals(context, result.ToLocalChecked()).FromJust()); |
170 } | 170 } |
171 } else { | 171 } else { |
172 CHECK(expectations == EXPECT_EXCEPTION); | 172 CHECK(expectations == EXPECT_EXCEPTION); |
173 CHECK(catcher.HasCaught()); | 173 CHECK(catcher.HasCaught()); |
174 if (!value.IsEmpty()) { | 174 if (!value.IsEmpty()) { |
175 CHECK(value->Equals(context, catcher.Exception()).FromJust()); | 175 CHECK(value->Equals(context, catcher.Exception()).FromJust()); |
176 } | 176 } |
177 } | 177 } |
178 // Clean slate for the next test. | 178 // Clean slate for the next test. |
179 CcTest::heap()->CollectAllAvailableGarbage(); | 179 CcTest::CollectAllAvailableGarbage(); |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 void DeclarationContext::HandleGet( | 183 void DeclarationContext::HandleGet( |
184 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>& info) { | 184 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>& info) { |
185 DeclarationContext* context = GetInstance(info.Data()); | 185 DeclarationContext* context = GetInstance(info.Data()); |
186 context->get_count_++; | 186 context->get_count_++; |
187 info.GetReturnValue().Set(context->Get(key)); | 187 info.GetReturnValue().Set(context->Get(key)); |
188 } | 188 } |
189 | 189 |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 Undefined(CcTest::isolate())); | 1177 Undefined(CcTest::isolate())); |
1178 for (int i = 0; i < 4; i++) { | 1178 for (int i = 0; i < 4; i++) { |
1179 context.Check("f()", EXPECT_EXCEPTION); | 1179 context.Check("f()", EXPECT_EXCEPTION); |
1180 } | 1180 } |
1181 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, | 1181 context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, |
1182 Undefined(CcTest::isolate())); | 1182 Undefined(CcTest::isolate())); |
1183 | 1183 |
1184 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 1184 context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); |
1185 } | 1185 } |
1186 } | 1186 } |
OLD | NEW |