OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 6724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6735 // multi-threaded setup. | 6735 // multi-threaded setup. |
6736 TEST(PreCompile) { | 6736 TEST(PreCompile) { |
6737 // TODO(155): This test would break without the initialization of V8. This is | 6737 // TODO(155): This test would break without the initialization of V8. This is |
6738 // a workaround for now to make this test not fail. | 6738 // a workaround for now to make this test not fail. |
6739 v8::V8::Initialize(); | 6739 v8::V8::Initialize(); |
6740 const char *script = "function foo(a) { return a+1; }"; | 6740 const char *script = "function foo(a) { return a+1; }"; |
6741 v8::ScriptData *sd = | 6741 v8::ScriptData *sd = |
6742 v8::ScriptData::PreCompile(script, i::StrLength(script)); | 6742 v8::ScriptData::PreCompile(script, i::StrLength(script)); |
6743 CHECK_NE(sd->Length(), 0); | 6743 CHECK_NE(sd->Length(), 0); |
6744 CHECK_NE(sd->Data(), NULL); | 6744 CHECK_NE(sd->Data(), NULL); |
| 6745 CHECK(!sd->HasError()); |
6745 delete sd; | 6746 delete sd; |
6746 } | 6747 } |
6747 | 6748 |
| 6749 |
| 6750 TEST(PreCompileWithError) { |
| 6751 v8::V8::Initialize(); |
| 6752 const char *script = "function foo(a) { return 1 * * 2; }"; |
| 6753 v8::ScriptData *sd = |
| 6754 v8::ScriptData::PreCompile(script, i::StrLength(script)); |
| 6755 CHECK(sd->HasError()); |
| 6756 delete sd; |
| 6757 } |
| 6758 |
| 6759 |
| 6760 TEST(Regress31661) { |
| 6761 v8::V8::Initialize(); |
| 6762 const char *script = " The Definintive Guide"; |
| 6763 v8::ScriptData *sd = |
| 6764 v8::ScriptData::PreCompile(script, i::StrLength(script)); |
| 6765 CHECK(sd->HasError()); |
| 6766 delete sd; |
| 6767 } |
| 6768 |
6748 | 6769 |
6749 // This tests that we do not allow dictionary load/call inline caches | 6770 // This tests that we do not allow dictionary load/call inline caches |
6750 // to use functions that have not yet been compiled. The potential | 6771 // to use functions that have not yet been compiled. The potential |
6751 // problem of loading a function that has not yet been compiled can | 6772 // problem of loading a function that has not yet been compiled can |
6752 // arise because we share code between contexts via the compilation | 6773 // arise because we share code between contexts via the compilation |
6753 // cache. | 6774 // cache. |
6754 THREADED_TEST(DictionaryICLoadedFunction) { | 6775 THREADED_TEST(DictionaryICLoadedFunction) { |
6755 v8::HandleScope scope; | 6776 v8::HandleScope scope; |
6756 // Test LoadIC. | 6777 // Test LoadIC. |
6757 for (int i = 0; i < 2; i++) { | 6778 for (int i = 0; i < 2; i++) { |
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8639 CompileRun(source_exception); | 8660 CompileRun(source_exception); |
8640 other_context->Exit(); | 8661 other_context->Exit(); |
8641 v8::internal::Heap::CollectAllGarbage(false); | 8662 v8::internal::Heap::CollectAllGarbage(false); |
8642 if (GetGlobalObjectsCount() == 1) break; | 8663 if (GetGlobalObjectsCount() == 1) break; |
8643 } | 8664 } |
8644 CHECK_GE(2, gc_count); | 8665 CHECK_GE(2, gc_count); |
8645 CHECK_EQ(1, GetGlobalObjectsCount()); | 8666 CHECK_EQ(1, GetGlobalObjectsCount()); |
8646 | 8667 |
8647 other_context.Dispose(); | 8668 other_context.Dispose(); |
8648 } | 8669 } |
OLD | NEW |