| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 #define THREADED_TEST(Name) \ | 148 #define THREADED_TEST(Name) \ |
| 149 static void Test##Name(); \ | 149 static void Test##Name(); \ |
| 150 RegisterThreadedTest register_##Name(Test##Name); \ | 150 RegisterThreadedTest register_##Name(Test##Name); \ |
| 151 /* */ TEST(Name) | 151 /* */ TEST(Name) |
| 152 | 152 |
| 153 | 153 |
| 154 class RegisterThreadedTest { | 154 class RegisterThreadedTest { |
| 155 public: | 155 public: |
| 156 explicit RegisterThreadedTest(CcTest::TestFunction* callback) | 156 explicit RegisterThreadedTest(CcTest::TestFunction* callback) |
| 157 : callback_(callback) { | 157 : fuzzer_(NULL), callback_(callback) { |
| 158 prev_ = first_; | 158 prev_ = first_; |
| 159 first_ = this; | 159 first_ = this; |
| 160 count_++; | 160 count_++; |
| 161 } | 161 } |
| 162 static int count() { return count_; } | 162 static int count() { return count_; } |
| 163 static RegisterThreadedTest* nth(int i) { | 163 static RegisterThreadedTest* nth(int i) { |
| 164 ASSERT(i < count()); | 164 ASSERT(i < count()); |
| 165 RegisterThreadedTest* current = first_; | 165 RegisterThreadedTest* current = first_; |
| 166 while (i > 0) { | 166 while (i > 0) { |
| 167 i--; | 167 i--; |
| (...skipping 4923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5091 v8::Unlocker unlocker; | 5091 v8::Unlocker unlocker; |
| 5092 // Wait till someone starts us again. | 5092 // Wait till someone starts us again. |
| 5093 gate_->Wait(); | 5093 gate_->Wait(); |
| 5094 // And we're off. | 5094 // And we're off. |
| 5095 } | 5095 } |
| 5096 } | 5096 } |
| 5097 | 5097 |
| 5098 | 5098 |
| 5099 void ApiTestFuzzer::TearDown() { | 5099 void ApiTestFuzzer::TearDown() { |
| 5100 fuzzing_ = false; | 5100 fuzzing_ = false; |
| 5101 for (int i = 0; i < RegisterThreadedTest::count(); i++) { |
| 5102 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_; |
| 5103 if (fuzzer != NULL) fuzzer->Join(); |
| 5104 } |
| 5101 } | 5105 } |
| 5102 | 5106 |
| 5103 | 5107 |
| 5104 // Lets not be needlessly self-referential. | 5108 // Lets not be needlessly self-referential. |
| 5105 TEST(Threading) { | 5109 TEST(Threading) { |
| 5106 ApiTestFuzzer::Setup(ApiTestFuzzer::FIRST_PART); | 5110 ApiTestFuzzer::Setup(ApiTestFuzzer::FIRST_PART); |
| 5107 ApiTestFuzzer::RunAllTests(); | 5111 ApiTestFuzzer::RunAllTests(); |
| 5108 ApiTestFuzzer::TearDown(); | 5112 ApiTestFuzzer::TearDown(); |
| 5109 } | 5113 } |
| 5110 | 5114 |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6111 // Check without 'eval' or 'with'. | 6115 // Check without 'eval' or 'with'. |
| 6112 v8::Handle<v8::Value> res = | 6116 v8::Handle<v8::Value> res = |
| 6113 CompileRun("function f() { x = 42; return x; }; f()"); | 6117 CompileRun("function f() { x = 42; return x; }; f()"); |
| 6114 // Check with 'eval'. | 6118 // Check with 'eval'. |
| 6115 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); | 6119 res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()"); |
| 6116 CHECK_EQ(v8::Integer::New(42), res); | 6120 CHECK_EQ(v8::Integer::New(42), res); |
| 6117 // Check with 'with'. | 6121 // Check with 'with'. |
| 6118 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); | 6122 res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()"); |
| 6119 CHECK_EQ(v8::Integer::New(42), res); | 6123 CHECK_EQ(v8::Integer::New(42), res); |
| 6120 } | 6124 } |
| OLD | NEW |