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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 void DeclarationContext::Check(const char* source, | 139 void DeclarationContext::Check(const char* source, |
140 int get, int set, int query, | 140 int get, int set, int query, |
141 Expectations expectations, | 141 Expectations expectations, |
142 v8::Handle<Value> value) { | 142 v8::Handle<Value> value) { |
143 InitializeIfNeeded(); | 143 InitializeIfNeeded(); |
144 // A retry after a GC may pollute the counts, so perform gc now | 144 // A retry after a GC may pollute the counts, so perform gc now |
145 // to avoid that. | 145 // to avoid that. |
146 HEAP->CollectGarbage(v8::internal::NEW_SPACE); | 146 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); |
147 HandleScope scope(CcTest::isolate()); | 147 HandleScope scope(CcTest::isolate()); |
148 TryCatch catcher; | 148 TryCatch catcher; |
149 catcher.SetVerbose(true); | 149 catcher.SetVerbose(true); |
150 Local<Script> script = Script::Compile(String::New(source)); | 150 Local<Script> script = Script::Compile(String::New(source)); |
151 if (expectations == EXPECT_ERROR) { | 151 if (expectations == EXPECT_ERROR) { |
152 CHECK(script.IsEmpty()); | 152 CHECK(script.IsEmpty()); |
153 return; | 153 return; |
154 } | 154 } |
155 CHECK(!script.IsEmpty()); | 155 CHECK(!script.IsEmpty()); |
156 Local<Value> result = script->Run(); | 156 Local<Value> result = script->Run(); |
157 CHECK_EQ(get, get_count()); | 157 CHECK_EQ(get, get_count()); |
158 CHECK_EQ(set, set_count()); | 158 CHECK_EQ(set, set_count()); |
159 CHECK_EQ(query, query_count()); | 159 CHECK_EQ(query, query_count()); |
160 if (expectations == EXPECT_RESULT) { | 160 if (expectations == EXPECT_RESULT) { |
161 CHECK(!catcher.HasCaught()); | 161 CHECK(!catcher.HasCaught()); |
162 if (!value.IsEmpty()) { | 162 if (!value.IsEmpty()) { |
163 CHECK_EQ(value, result); | 163 CHECK_EQ(value, result); |
164 } | 164 } |
165 } else { | 165 } else { |
166 CHECK(expectations == EXPECT_EXCEPTION); | 166 CHECK(expectations == EXPECT_EXCEPTION); |
167 CHECK(catcher.HasCaught()); | 167 CHECK(catcher.HasCaught()); |
168 if (!value.IsEmpty()) { | 168 if (!value.IsEmpty()) { |
169 CHECK_EQ(value, catcher.Exception()); | 169 CHECK_EQ(value, catcher.Exception()); |
170 } | 170 } |
171 } | 171 } |
172 HEAP->CollectAllAvailableGarbage(); // Clean slate for the next test. | 172 // Clean slate for the next test. |
| 173 CcTest::heap()->CollectAllAvailableGarbage(); |
173 } | 174 } |
174 | 175 |
175 | 176 |
176 void DeclarationContext::HandleGet( | 177 void DeclarationContext::HandleGet( |
177 Local<String> key, | 178 Local<String> key, |
178 const v8::PropertyCallbackInfo<v8::Value>& info) { | 179 const v8::PropertyCallbackInfo<v8::Value>& info) { |
179 DeclarationContext* context = GetInstance(info.Data()); | 180 DeclarationContext* context = GetInstance(info.Data()); |
180 context->get_count_++; | 181 context->get_count_++; |
181 info.GetReturnValue().Set(context->Get(key)); | 182 info.GetReturnValue().Set(context->Get(key)); |
182 } | 183 } |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 SimpleContext context; | 847 SimpleContext context; |
847 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); | 848 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); |
848 // TODO(rossberg): All tests should actually be errors in Harmony, | 849 // TODO(rossberg): All tests should actually be errors in Harmony, |
849 // but we currently do not detect the cases where the first declaration | 850 // but we currently do not detect the cases where the first declaration |
850 // is not lexical. | 851 // is not lexical. |
851 context.Check(seconds[j], | 852 context.Check(seconds[j], |
852 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); | 853 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); |
853 } | 854 } |
854 } | 855 } |
855 } | 856 } |
OLD | NEW |