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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class DeclarationContext { | 49 class DeclarationContext { |
50 public: | 50 public: |
51 DeclarationContext(); | 51 DeclarationContext(); |
52 | 52 |
53 virtual ~DeclarationContext() { | 53 virtual ~DeclarationContext() { |
54 if (is_initialized_) { | 54 if (is_initialized_) { |
55 Isolate* isolate = CcTest::isolate(); | 55 Isolate* isolate = CcTest::isolate(); |
56 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
57 Local<Context> context = Local<Context>::New(isolate, context_); | 57 Local<Context> context = Local<Context>::New(isolate, context_); |
58 context->Exit(); | 58 context->Exit(); |
59 context_.Dispose(); | 59 context_.Reset(); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void Check(const char* source, | 63 void Check(const char* source, |
64 int get, int set, int has, | 64 int get, int set, int has, |
65 Expectations expectations, | 65 Expectations expectations, |
66 v8::Handle<Value> value = Local<Value>()); | 66 v8::Handle<Value> value = Local<Value>()); |
67 | 67 |
68 int get_count() const { return get_count_; } | 68 int get_count() const { return get_count_; } |
69 int set_count() const { return set_count_; } | 69 int set_count() const { return set_count_; } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CcTest::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 = |
| 151 Script::Compile(String::NewFromUtf8(CcTest::isolate(), source)); |
151 if (expectations == EXPECT_ERROR) { | 152 if (expectations == EXPECT_ERROR) { |
152 CHECK(script.IsEmpty()); | 153 CHECK(script.IsEmpty()); |
153 return; | 154 return; |
154 } | 155 } |
155 CHECK(!script.IsEmpty()); | 156 CHECK(!script.IsEmpty()); |
156 Local<Value> result = script->Run(); | 157 Local<Value> result = script->Run(); |
157 CHECK_EQ(get, get_count()); | 158 CHECK_EQ(get, get_count()); |
158 CHECK_EQ(set, set_count()); | 159 CHECK_EQ(set, set_count()); |
159 CHECK_EQ(query, query_count()); | 160 CHECK_EQ(query, query_count()); |
160 if (expectations == EXPECT_RESULT) { | 161 if (expectations == EXPECT_RESULT) { |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 ~SimpleContext() { | 723 ~SimpleContext() { |
723 context_->Exit(); | 724 context_->Exit(); |
724 } | 725 } |
725 | 726 |
726 void Check(const char* source, | 727 void Check(const char* source, |
727 Expectations expectations, | 728 Expectations expectations, |
728 v8::Handle<Value> value = Local<Value>()) { | 729 v8::Handle<Value> value = Local<Value>()) { |
729 HandleScope scope(context_->GetIsolate()); | 730 HandleScope scope(context_->GetIsolate()); |
730 TryCatch catcher; | 731 TryCatch catcher; |
731 catcher.SetVerbose(true); | 732 catcher.SetVerbose(true); |
732 Local<Script> script = Script::Compile(String::New(source)); | 733 Local<Script> script = |
| 734 Script::Compile(String::NewFromUtf8(context_->GetIsolate(), source)); |
733 if (expectations == EXPECT_ERROR) { | 735 if (expectations == EXPECT_ERROR) { |
734 CHECK(script.IsEmpty()); | 736 CHECK(script.IsEmpty()); |
735 return; | 737 return; |
736 } | 738 } |
737 CHECK(!script.IsEmpty()); | 739 CHECK(!script.IsEmpty()); |
738 Local<Value> result = script->Run(); | 740 Local<Value> result = script->Run(); |
739 if (expectations == EXPECT_RESULT) { | 741 if (expectations == EXPECT_RESULT) { |
740 CHECK(!catcher.HasCaught()); | 742 CHECK(!catcher.HasCaught()); |
741 if (!value.IsEmpty()) { | 743 if (!value.IsEmpty()) { |
742 CHECK_EQ(value, result); | 744 CHECK_EQ(value, result); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 SimpleContext context; | 856 SimpleContext context; |
855 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); | 857 context.Check(firsts[i], EXPECT_RESULT, Number::New(1)); |
856 // TODO(rossberg): All tests should actually be errors in Harmony, | 858 // TODO(rossberg): All tests should actually be errors in Harmony, |
857 // but we currently do not detect the cases where the first declaration | 859 // but we currently do not detect the cases where the first declaration |
858 // is not lexical. | 860 // is not lexical. |
859 context.Check(seconds[j], | 861 context.Check(seconds[j], |
860 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); | 862 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, Number::New(2)); |
861 } | 863 } |
862 } | 864 } |
863 } | 865 } |
OLD | NEW |