diff options
author | Ben Murdoch <benm@google.com> | 2011-11-30 16:04:58 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-12-02 17:28:30 +0000 |
commit | 589d6979ff2ef66fca2d8fa51404c369ca5e9250 (patch) | |
tree | 1d9032fcae9d18a05430a4ba9c14e5c635c4096e /test | |
parent | 69a99ed0b2b2ef69d393c371b03db3a98aaf880e (diff) | |
download | v8-589d6979ff2ef66fca2d8fa51404c369ca5e9250.tar.gz |
Upgrade to V8 3.6
Merge V8 at 3.6.6.11
Simple merge required updates to makefiles only.
Bug: 5688872
Change-Id: Ib38b7ffbcd409585f6cb6fccc59c767029cecc77
Diffstat (limited to 'test')
110 files changed, 2355 insertions, 383 deletions
diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp index c0b53163..5d0cab3e 100644 --- a/test/cctest/cctest.gyp +++ b/test/cctest/cctest.gyp @@ -35,7 +35,6 @@ 'target_name': 'cctest', 'type': 'executable', 'dependencies': [ - '../../tools/gyp/v8.gyp:v8', 'resources', ], 'include_dirs': [ @@ -136,6 +135,20 @@ 'test-platform-win32.cc', ], }], + ['component=="shared_library"', { + # cctest can't be built against a shared library, so we need to + # depend on the underlying static target in that case. + 'conditions': [ + ['v8_use_snapshot=="true"', { + 'dependencies': ['../../tools/gyp/v8.gyp:v8_snapshot'], + }, + { + 'dependencies': ['../../tools/gyp/v8.gyp:v8_nosnapshot'], + }], + ], + }, { + 'dependencies': ['../../tools/gyp/v8.gyp:v8'], + }], ], }, { diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index b0b8eb72..c04d893c 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -110,6 +110,7 @@ class ApiTestFuzzer: public v8::internal::Thread { // This method switches threads if we are running the Threading test. // Otherwise it does nothing. static void Fuzz(); + private: static bool fuzzing_; static int tests_being_run_; diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status index 78f37561..5122da5a 100644 --- a/test/cctest/cctest.status +++ b/test/cctest/cctest.status @@ -76,3 +76,7 @@ test-debug/DebugBreakLoop: SKIP [ $arch == mips ] test-deoptimization: SKIP test-serialize: SKIP + +# Tests that may time out. +test-api/ExternalArrays: PASS || TIMEOUT +test-api/Threading: PASS || TIMEOUT diff --git a/test/cctest/log-eq-of-logging-and-traversal.js b/test/cctest/log-eq-of-logging-and-traversal.js index cd52da54..05643bfb 100644 --- a/test/cctest/log-eq-of-logging-and-traversal.js +++ b/test/cctest/log-eq-of-logging-and-traversal.js @@ -43,8 +43,7 @@ function LogProcessor() { processor: this.processCodeCreation }, 'code-move': { parsers: [parseInt, parseInt], processor: this.processCodeMove }, - 'code-delete': { parsers: [parseInt], - processor: this.processCodeDelete }, + 'code-delete': null, 'sfi-move': { parsers: [parseInt, parseInt], processor: this.processFunctionMove }, 'shared-library': null, @@ -73,10 +72,6 @@ LogProcessor.prototype.processCodeMove = function(from, to) { this.profile.moveCode(from, to); }; -LogProcessor.prototype.processCodeDelete = function(start) { - this.profile.deleteCode(start); -}; - LogProcessor.prototype.processFunctionMove = function(from, to) { this.profile.moveFunc(from, to); }; @@ -132,8 +127,8 @@ function RunTest() { "Script", "String", "RegExp", "Date", "Error"]; function entitiesEqual(entityA, entityB) { - if (entityA === null && entityB !== null) return true; - if (entityA !== null && entityB === null) return false; + if ((entityA === null && entityB !== null) || + (entityA !== null && entityB === null)) return true; return entityA.size === entityB.size && entityNamesEqual(entityA, entityB); } @@ -145,6 +140,8 @@ function RunTest() { // find the same entries. We skip builtins during log parsing, but compiled // functions traversal may erroneously recognize them as functions, so we are // expecting more functions in traversal vs. logging. + // Since we don't track code deletions, logging can also report more entries + // than traversal. while (l_pos < l_len && t_pos < t_len) { var entryA = logging_entries[l_pos]; var entryB = traversal_entries[t_pos]; @@ -166,11 +163,6 @@ function RunTest() { if (!entities_equal) equal = false; comparison.push([entities_equal, address, entityA, entityB]); } - if (l_pos < l_len) equal = false; - while (l_pos < l_len) { - var entryA = logging_entries[l_pos++]; - comparison.push([false, entryA[0], entryA[1], null]); - } return [equal, comparison]; } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 3d40a730..c1c8aae5 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -4254,7 +4254,7 @@ template <typename T> static void USE(T) { } // This test is not intended to be run, just type checked. -static void PersistentHandles() { +static inline void PersistentHandles() { USE(PersistentHandles); Local<String> str = v8_str("foo"); v8::Persistent<String> p_str = v8::Persistent<String>::New(str); @@ -11821,14 +11821,21 @@ THREADED_TEST(PixelArray) { CHECK_EQ(28, result->Int32Value()); i::Handle<i::Smi> value(i::Smi::FromInt(2)); - i::SetElement(jsobj, 1, value, i::kNonStrictMode); + i::Handle<i::Object> no_failure; + no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); + ASSERT(!no_failure.is_null()); + i::USE(no_failure); CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); *value.location() = i::Smi::FromInt(256); - i::SetElement(jsobj, 1, value, i::kNonStrictMode); + no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); + ASSERT(!no_failure.is_null()); + i::USE(no_failure); CHECK_EQ(255, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); *value.location() = i::Smi::FromInt(-1); - i::SetElement(jsobj, 1, value, i::kNonStrictMode); + no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode); + ASSERT(!no_failure.is_null()); + i::USE(no_failure); CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value()); result = CompileRun("for (var i = 0; i < 8; i++) {" diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc index ca11a2ae..a6c76f03 100644 --- a/test/cctest/test-assembler-mips.cc +++ b/test/cctest/test-assembler-mips.cc @@ -774,7 +774,7 @@ TEST(MIPS10) { Assembler assm(Isolate::Current(), NULL, 0); Label L, C; - if (CpuFeatures::IsSupported(FPU)) { + if (CpuFeatures::IsSupported(FPU) && mips32r2) { CpuFeatures::Scope scope(FPU); // Load all structure elements to registers. @@ -1268,7 +1268,9 @@ TEST(MIPS15) { Label target; __ beq(v0, v1, &target); + __ nop(); __ bne(v0, v1, &target); + __ nop(); __ bind(&target); __ nop(); } diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 8f226f6c..2d9b0120 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdlib.h> -#include <wchar.h> // wint_t +#include <wchar.h> #include "v8.h" @@ -75,7 +75,7 @@ v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) { uint16_t* string = NewArray<uint16_t>(length + 1); string_obj->Write(string); for (int j = 0; j < length; j++) - printf("%lc", static_cast<wint_t>(string[j])); + printf("%lc", static_cast<wchar_t>(string[j])); DeleteArray(string); } printf("\n"); diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 81c487da..f567a0f7 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -107,7 +107,7 @@ TEST(CodeEvents) { 0x80); processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500)); processor.CodeCreateEvent(i::Logger::STUB_TAG, 3, ToAddress(0x1600), 0x10); - processor.CodeDeleteEvent(ToAddress(0x1600)); + processor.CodeCreateEvent(i::Logger::STUB_TAG, 4, ToAddress(0x1605), 0x10); // Enqueue a tick event to enable code events processing. EnqueueTickSampleEvent(&processor, ToAddress(0x1000)); diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index b7962de2..45da6dc0 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -157,6 +157,7 @@ class DebugLocalContext { Handle<Object>(debug->debug_context()->global_proxy()), DONT_ENUM, ::v8::internal::kNonStrictMode); } + private: v8::Persistent<v8::Context> context_; }; @@ -5916,7 +5917,7 @@ class DebuggerAgentProtocolServerThread : public i::Thread { private: int port_; - i::SmartPointer<char> body_; + i::SmartArrayPointer<char> body_; i::Socket* server_; // Server socket used for bind/accept. i::Socket* client_; // Single client connection used by the test. i::Semaphore* listening_; // Signalled when the server is in listen mode. diff --git a/test/cctest/test-disasm-mips.cc b/test/cctest/test-disasm-mips.cc index 901dbc1b..5ad99d7a 100644 --- a/test/cctest/test-disasm-mips.cc +++ b/test/cctest/test-disasm-mips.cc @@ -274,23 +274,25 @@ TEST(Type0) { COMPARE(srav(v0, v1, fp), "03c31007 srav v0, v1, fp"); - COMPARE(rotr(a0, a1, 0), - "00252002 rotr a0, a1, 0"); - COMPARE(rotr(s0, s1, 8), - "00318202 rotr s0, s1, 8"); - COMPARE(rotr(t2, t3, 24), - "002b5602 rotr t2, t3, 24"); - COMPARE(rotr(v0, v1, 31), - "002317c2 rotr v0, v1, 31"); - - COMPARE(rotrv(a0, a1, a2), - "00c52046 rotrv a0, a1, a2"); - COMPARE(rotrv(s0, s1, s2), - "02518046 rotrv s0, s1, s2"); - COMPARE(rotrv(t2, t3, t4), - "018b5046 rotrv t2, t3, t4"); - COMPARE(rotrv(v0, v1, fp), - "03c31046 rotrv v0, v1, fp"); + if (mips32r2) { + COMPARE(rotr(a0, a1, 0), + "00252002 rotr a0, a1, 0"); + COMPARE(rotr(s0, s1, 8), + "00318202 rotr s0, s1, 8"); + COMPARE(rotr(t2, t3, 24), + "002b5602 rotr t2, t3, 24"); + COMPARE(rotr(v0, v1, 31), + "002317c2 rotr v0, v1, 31"); + + COMPARE(rotrv(a0, a1, a2), + "00c52046 rotrv a0, a1, a2"); + COMPARE(rotrv(s0, s1, s2), + "02518046 rotrv s0, s1, s2"); + COMPARE(rotrv(t2, t3, t4), + "018b5046 rotrv t2, t3, t4"); + COMPARE(rotrv(v0, v1, fp), + "03c31046 rotrv v0, v1, fp"); + } COMPARE(break_(0), "0000000d break, code: 0x00000 (0)"); @@ -415,18 +417,21 @@ TEST(Type0) { "72f6b020 clz s6, s7"); COMPARE(clz(v0, v1), "70621020 clz v0, v1"); - COMPARE(ins_(a0, a1, 31, 1), - "7ca4ffc4 ins a0, a1, 31, 1"); - COMPARE(ins_(s6, s7, 30, 2), - "7ef6ff84 ins s6, s7, 30, 2"); - COMPARE(ins_(v0, v1, 0, 32), - "7c62f804 ins v0, v1, 0, 32"); - COMPARE(ext_(a0, a1, 31, 1), - "7ca407c0 ext a0, a1, 31, 1"); - COMPARE(ext_(s6, s7, 30, 2), - "7ef60f80 ext s6, s7, 30, 2"); - COMPARE(ext_(v0, v1, 0, 32), - "7c62f800 ext v0, v1, 0, 32"); + + if (mips32r2) { + COMPARE(ins_(a0, a1, 31, 1), + "7ca4ffc4 ins a0, a1, 31, 1"); + COMPARE(ins_(s6, s7, 30, 2), + "7ef6ff84 ins s6, s7, 30, 2"); + COMPARE(ins_(v0, v1, 0, 32), + "7c62f804 ins v0, v1, 0, 32"); + COMPARE(ext_(a0, a1, 31, 1), + "7ca407c0 ext a0, a1, 31, 1"); + COMPARE(ext_(s6, s7, 30, 2), + "7ef60f80 ext s6, s7, 30, 2"); + COMPARE(ext_(v0, v1, 0, 32), + "7c62f800 ext v0, v1, 0, 32"); + } VERIFY_RUN(); } diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc index bb930c8a..8f405b72 100644 --- a/test/cctest/test-func-name-inference.cc +++ b/test/cctest/test-func-name-inference.cc @@ -41,7 +41,7 @@ using ::v8::internal::JSFunction; using ::v8::internal::Object; using ::v8::internal::Runtime; using ::v8::internal::Script; -using ::v8::internal::SmartPointer; +using ::v8::internal::SmartArrayPointer; using ::v8::internal::SharedFunctionInfo; using ::v8::internal::String; @@ -96,7 +96,7 @@ static void CheckFunctionName(v8::Handle<v8::Script> script, SharedFunctionInfo::cast(shared_func_info_ptr)); // Verify inferred function name. - SmartPointer<char> inferred_name = + SmartArrayPointer<char> inferred_name = shared_func_info->inferred_name()->ToCString(); CHECK_EQ(ref_inferred_name, *inferred_name); #endif // ENABLE_DEBUGGER_SUPPORT diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index 143a23cb..6c2afd47 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -948,7 +948,7 @@ TEST(GetHeapValueForDeletedObject) { static int StringCmp(const char* ref, i::String* act) { - i::SmartPointer<char> s_act = act->ToCString(); + i::SmartArrayPointer<char> s_act = act->ToCString(); int result = strcmp(ref, *s_act); if (result != 0) fprintf(stderr, "Expected: \"%s\", Actual: \"%s\"\n", ref, *s_act); diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc index d61fde25..7360da52 100644 --- a/test/cctest/test-lockers.cc +++ b/test/cctest/test-lockers.cc @@ -142,6 +142,7 @@ class JoinableThread { } virtual void Run() = 0; + private: class ThreadWithSemaphore : public i::Thread { public: @@ -377,6 +378,7 @@ class LockerUnlockerThread : public JoinableThread { CalcFibAndCheck(); } } + private: v8::Isolate* isolate_; }; @@ -429,6 +431,7 @@ class LockTwiceAndUnlockThread : public JoinableThread { CalcFibAndCheck(); } } + private: v8::Isolate* isolate_; }; @@ -498,6 +501,7 @@ class LockAndUnlockDifferentIsolatesThread : public JoinableThread { thread.Join(); } } + private: v8::Isolate* isolate1_; v8::Isolate* isolate2_; diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc index dfbc733e..72e663c4 100644 --- a/test/cctest/test-log.cc +++ b/test/cctest/test-log.cc @@ -25,6 +25,7 @@ using v8::internal::StrLength; namespace { + class ScopedLoggerInitializer { public: explicit ScopedLoggerInitializer(bool prof_lazy) @@ -470,8 +471,9 @@ TEST(IsLoggingPreserved) { typedef i::NativesCollection<i::TEST> TestSources; -// Test that logging of code create / move / delete events -// is equivalent to traversal of a resulting heap. + +// Test that logging of code create / move events is equivalent to traversal of +// a resulting heap. TEST(EquivalenceOfLoggingAndTraversal) { // This test needs to be run on a "clean" V8 to ensure that snapshot log // is loaded. This is always true when running using tools/test.py because diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index 8b6afdc5..f5aed96d 100755 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -31,14 +31,14 @@ #include "v8.h" +#include "cctest.h" +#include "execution.h" #include "isolate.h" -#include "token.h" -#include "scanner.h" #include "parser.h" -#include "utils.h" -#include "execution.h" #include "preparser.h" -#include "cctest.h" +#include "scanner-character-streams.h" +#include "token.h" +#include "utils.h" TEST(ScanKeywords) { struct KeywordToken { @@ -345,7 +345,7 @@ TEST(PreParseOverflow) { reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); size_t kProgramSize = 1024 * 1024; - i::SmartPointer<char> program( + i::SmartArrayPointer<char> program( reinterpret_cast<char*>(malloc(kProgramSize + 1))); memset(*program, '(', kProgramSize); program[kProgramSize] = '\0'; @@ -398,7 +398,7 @@ void TestCharacterStream(const char* ascii_source, if (end == 0) end = length; unsigned sub_length = end - start; i::HandleScope test_scope; - i::SmartPointer<i::uc16> uc16_buffer(new i::uc16[length]); + i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]); for (unsigned i = 0; i < length; i++) { uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]); } diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index 250ebd4a..76fd244e 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -37,16 +37,16 @@ TEST(TokenEnumerator) { TokenEnumerator te; CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); v8::HandleScope hs; - v8::Local<v8::String> token1(v8::String::New("1")); + v8::Local<v8::String> token1(v8::String::New("1x")); CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); - v8::Local<v8::String> token2(v8::String::New("2")); + v8::Local<v8::String> token2(v8::String::New("2x")); CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); { v8::HandleScope hs; - v8::Local<v8::String> token3(v8::String::New("3")); + v8::Local<v8::String> token3(v8::String::New("3x")); CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); @@ -549,13 +549,14 @@ TEST(CodeMapMoveAndDeleteCode) { code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); - code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1800)); + code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); - CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); - CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); - code_map.DeleteCode(ToAddress(0x1700)); + CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, + TokenEnumerator::kNoSecurityToken); + code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); - CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); + CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); } diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc index 9f18b600..89a91127 100644 --- a/test/cctest/test-regexp.cc +++ b/test/cctest/test-regexp.cc @@ -30,14 +30,15 @@ #include "v8.h" -#include "string-stream.h" -#include "cctest.h" -#include "zone-inl.h" -#include "parser.h" #include "ast.h" +#include "char-predicates-inl.h" +#include "cctest.h" #include "jsregexp.h" +#include "parser.h" #include "regexp-macro-assembler.h" #include "regexp-macro-assembler-irregexp.h" +#include "string-stream.h" +#include "zone-inl.h" #ifdef V8_INTERPRETED_REGEXP #include "interpreter-irregexp.h" #else // V8_INTERPRETED_REGEXP @@ -78,7 +79,7 @@ static bool CheckParse(const char* input) { } -static SmartPointer<const char> Parse(const char* input) { +static SmartArrayPointer<const char> Parse(const char* input) { V8::Initialize(NULL); v8::HandleScope scope; ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); @@ -87,7 +88,7 @@ static SmartPointer<const char> Parse(const char* input) { CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree != NULL); CHECK(result.error.is_null()); - SmartPointer<const char> output = result.tree->ToString(); + SmartArrayPointer<const char> output = result.tree->ToString(); return output; } @@ -390,7 +391,7 @@ static void ExpectError(const char* input, CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree == NULL); CHECK(!result.error.is_null()); - SmartPointer<char> str = result.error->ToCString(ALLOW_NULLS); + SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); CHECK_EQ(expected, *str); } @@ -422,7 +423,7 @@ TEST(Errors) { for (int i = 0; i <= kMaxCaptures; i++) { accumulator.Add("()"); } - SmartPointer<const char> many_captures(accumulator.ToCString()); + SmartArrayPointer<const char> many_captures(accumulator.ToCString()); ExpectError(*many_captures, kTooManyCaptures); } diff --git a/test/cctest/test-reloc-info.cc b/test/cctest/test-reloc-info.cc index 0378fb34..5bdc4c3e 100644 --- a/test/cctest/test-reloc-info.cc +++ b/test/cctest/test-reloc-info.cc @@ -45,7 +45,7 @@ TEST(Positions) { const int code_size = 10 * KB; int relocation_info_size = 10 * KB; const int buffer_size = code_size + relocation_info_size; - SmartPointer<byte> buffer(new byte[buffer_size]); + SmartArrayPointer<byte> buffer(new byte[buffer_size]); byte* pc = *buffer; byte* buffer_end = *buffer + buffer_size; diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc index 17020a32..55c21417 100644 --- a/test/cctest/test-strings.cc +++ b/test/cctest/test-strings.cc @@ -529,3 +529,32 @@ TEST(TrivialSlice) { CHECK(string->IsSlicedString()); CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); } + + +TEST(SliceFromSlice) { + // This tests whether a slice that contains the entire parent string + // actually creates a new string (it should not). + FLAG_string_slices = true; + InitializeVM(); + HandleScope scope; + v8::Local<v8::Value> result; + Handle<String> string; + const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; + const char* slice = "var slice = str.slice(1,-1); slice"; + const char* slice_from_slice = "slice.slice(1,-1);"; + + CompileRun(init); + result = CompileRun(slice); + CHECK(result->IsString()); + string = v8::Utils::OpenHandle(v8::String::Cast(*result)); + CHECK(string->IsSlicedString()); + CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); + CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); + + result = CompileRun(slice_from_slice); + CHECK(result->IsString()); + string = v8::Utils::OpenHandle(v8::String::Cast(*result)); + CHECK(string->IsSlicedString()); + CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); + CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); +} diff --git a/test/cctest/test-threads.cc b/test/cctest/test-threads.cc index 59d27ab7..985b9e5b 100644 --- a/test/cctest/test-threads.cc +++ b/test/cctest/test-threads.cc @@ -161,6 +161,7 @@ class ThreadIdValidationThread : public v8::internal::Thread { } semaphore_->Signal(); } + private: i::List<i::ThreadId>* refs_; int thread_no_; diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc index e1368583..e4f70df4 100644 --- a/test/cctest/test-utils.cc +++ b/test/cctest/test-utils.cc @@ -195,3 +195,15 @@ TEST(SequenceCollector) { } result.Dispose(); } + + +TEST(SequenceCollectorRegression) { + SequenceCollector<char> collector(16); + collector.StartSequence(); + collector.Add('0'); + collector.AddBlock( + i::Vector<const char>("12345678901234567890123456789012", 32)); + i::Vector<char> seq = collector.EndSequence(); + CHECK_EQ(0, strncmp("0123456789012345678901234567890123", + seq.start(), seq.length())); +} diff --git a/test/es5conform/es5conform.status b/test/es5conform/es5conform.status index 55712baf..d095a247 100644 --- a/test/es5conform/es5conform.status +++ b/test/es5conform/es5conform.status @@ -75,11 +75,11 @@ chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-214: UNIMPLEMENTED # NOT IMPLEMENTED: RegExp.prototype.multiline chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-215: UNIMPLEMENTED -# All of the tests below marked SUBSETFAIL (in 15.2.3.4) fail because +# All of the tests below marked SUBSETFAIL (in 15.2.3.4) fail because # the tests assumes that objects can not have more properties -# than those described in the spec - but according to spec they can +# than those described in the spec - but according to spec they can # have additional properties. -# All compareArray calls in these tests could be exchanged with a +# All compareArray calls in these tests could be exchanged with a # isSubsetOfArray call (I will upload a patch to the es5conform site). # SUBSETFAIL diff --git a/test/mjsunit/array-constructor.js b/test/mjsunit/array-constructor.js index 063ccde5..bf5d3d61 100644 --- a/test/mjsunit/array-constructor.js +++ b/test/mjsunit/array-constructor.js @@ -73,7 +73,7 @@ for (var i = 0; i < loop_count; i++) { a = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8); assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8], a); a = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); - assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], a); + assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], a); } @@ -91,9 +91,9 @@ function testConstructOfSizeSize(n) { var a = eval('[' + str + ']'); var b = eval('new Array(' + str + ')') var c = eval('Array(' + str + ')') - assertEquals(n, a.length); - assertArrayEquals(a, b); - assertArrayEquals(a, c); + assertEquals(n, a.length); + assertArrayEquals(a, b); + assertArrayEquals(a, c); } diff --git a/test/mjsunit/array-iteration.js b/test/mjsunit/array-iteration.js index f11b51cb..0ee2e6e9 100644 --- a/test/mjsunit/array-iteration.js +++ b/test/mjsunit/array-iteration.js @@ -134,7 +134,7 @@ a = [0,1]; assertFalse(a.every(function(n, index, array) { array[index] = n + 1; return n == 1;})); assertArrayEquals([1,1], a); - + // Only loop through initial part of array eventhough elements are // added. a = [1,1]; @@ -156,23 +156,23 @@ // (function() { var a = [0,1,2,3,4]; - + // Simple use. var result = [1,2,3,4,5]; assertArrayEquals(result, a.map(function(n) { return n + 1; })); assertEquals(a, a); - + // Use specified object as this object when calling the function. var o = { delta: 42 } result = [42,43,44,45,46]; assertArrayEquals(result, a.map(function(n) { return this.delta + n; }, o)); - + // Modify original array. a = [0,1,2,3,4]; result = [1,2,3,4,5]; assertArrayEquals(result, a.map(function(n, index, array) { array[index] = n + 1; return n + 1;})); assertArrayEquals(result, a); - + // Only loop through initial part of array eventhough elements are // added. a = [0,1,2,3,4]; @@ -197,7 +197,7 @@ // Simple use. assertTrue(a.some(function(n) { return n == 3})); assertFalse(a.some(function(n) { return n == 5})); - + // Use specified object as this object when calling the function. var o = { element: 42 }; a = [1,42,3]; diff --git a/test/mjsunit/array-sort.js b/test/mjsunit/array-sort.js index fd18a5b2..3fa623a6 100644 --- a/test/mjsunit/array-sort.js +++ b/test/mjsunit/array-sort.js @@ -392,7 +392,7 @@ TestSpecialCasesInheritedElementSort(); // Test that sort calls compare function with global object as receiver, // and with only elements of the array as arguments. -function o(v) { +function o(v) { return {__proto__: o.prototype, val: v}; } var arr = [o(1), o(2), o(4), o(8), o(16), o(32), o(64), o(128), o(256), o(-0)]; diff --git a/test/mjsunit/bugs/618.js b/test/mjsunit/bugs/618.js index afa9929a..ddc0c19c 100644 --- a/test/mjsunit/bugs/618.js +++ b/test/mjsunit/bugs/618.js @@ -32,14 +32,14 @@ function C1() { var c1 = new C1(); assertEquals(23, c1.x); assertEquals("undefined", typeof c1.y); - + // Add setter somewhere on the prototype chain after having constructed the // first instance. C1.prototype = { set x(value) { this.y = 23; } }; var c1 = new C1(); assertEquals("undefined", typeof c1.x); assertEquals(23, c1.y); - + // Simple class using inline constructor. function C2() { this.x = 23; diff --git a/test/mjsunit/bugs/bug-618.js b/test/mjsunit/bugs/bug-618.js index 8f474403..ae843267 100644 --- a/test/mjsunit/bugs/bug-618.js +++ b/test/mjsunit/bugs/bug-618.js @@ -33,11 +33,11 @@ function C() { this.x = 23; } -// If a setter is added to the prototype chain of a simple constructor setting -// one of the properties assigned in the constructor then this setter is +// If a setter is added to the prototype chain of a simple constructor setting +// one of the properties assigned in the constructor then this setter is // ignored when constructing new objects from the constructor. -// This only happens if the setter is added _after_ an instance has been +// This only happens if the setter is added _after_ an instance has been // created. assertEquals(23, new C().x); diff --git a/test/mjsunit/builtins.js b/test/mjsunit/builtins.js new file mode 100644 index 00000000..f2ad5446 --- /dev/null +++ b/test/mjsunit/builtins.js @@ -0,0 +1,82 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-natives-as=builtins + +// Checks that all function properties of the builtin object are neither +// writable nor configurable. Also, theose functions that are actually +// constructors (recognized by having properties on their .prototype object), +// have only unconfigurable properties on the prototype, and the methods +// are also non-writable. + +var names = Object.getOwnPropertyNames(builtins); + +function isFunction(obj) { + return typeof obj == "function"; +} + +function checkConstructor(func, name) { + // A constructor is a function with a prototype and properties on the + // prototype object besides "constructor"; + if (name.charAt(0) == "$") return; + if (typeof func.prototype != "object") return; + var propNames = Object.getOwnPropertyNames(func.prototype); + if (propNames.length == 0 || + (propNames.length == 1 && propNames[0] == "constructor")) { + // Not a constructor. + return; + } + var proto_desc = Object.getOwnPropertyDescriptor(func, "prototype"); + assertTrue(proto_desc.hasOwnProperty("value"), name); + assertFalse(proto_desc.writable, name); + assertFalse(proto_desc.configurable, name); + var prototype = proto_desc.value; + assertEquals(null, prototype.__proto__, name); + for (var i = 0; i < propNames.length; i++) { + var propName = propNames[i]; + if (propName == "constructor") continue; + var testName = name + "-" + propName; + var propDesc = Object.getOwnPropertyDescriptor(prototype, propName); + assertTrue(propDesc.hasOwnProperty("value"), testName); + assertFalse(propDesc.configurable, testName); + if (isFunction(propDesc.value)) { + assertFalse(propDesc.writable, testName); + } + } +} + +for (var i = 0; i < names.length; i++) { + var name = names[i]; + var desc = Object.getOwnPropertyDescriptor(builtins, name); + assertTrue(desc.hasOwnProperty("value")); + var value = desc.value; + if (isFunction(value)) { + assertFalse(desc.writable, name); + assertFalse(desc.configurable, name); + checkConstructor(value, name); + } +} diff --git a/test/mjsunit/compiler/delete.js b/test/mjsunit/compiler/delete.js index 373a1cbc..2aaecb25 100644 --- a/test/mjsunit/compiler/delete.js +++ b/test/mjsunit/compiler/delete.js @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -66,6 +66,7 @@ assertEquals(2, ((delete 0) || 2) + 1); assertEquals(3, (function (x) { return ((delete x) || 2) + 1; })(0)); -// 'this' at toplevel is different from all other global variables---not -// deletable. +// 'this' is not a Reference so delete returns true (see section 11.4.1, +// step 2 of ES 5.1). assertEquals(true, delete this); +assertEquals(true, (function () { return delete this; })()); diff --git a/test/mjsunit/compiler/global-accessors.js b/test/mjsunit/compiler/global-accessors.js index bd031a83..337424dc 100644 --- a/test/mjsunit/compiler/global-accessors.js +++ b/test/mjsunit/compiler/global-accessors.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This test tests that no bailouts are missing by not hitting asserts in debug -// mode. +// mode. test_count_operation() test_compound_assignment() diff --git a/test/mjsunit/const-redecl.js b/test/mjsunit/const-redecl.js index 26d765b9..94597089 100644 --- a/test/mjsunit/const-redecl.js +++ b/test/mjsunit/const-redecl.js @@ -55,7 +55,7 @@ function TestLocal(s,e) { function TestGlobal(s,e) { // Collect the global properties before the call. var properties = []; - for (var key in this) properties.push(key); + for (var key in this) properties.push(key); // Compute the result. var result; try { @@ -113,7 +113,7 @@ function TestConflict(def0, def1) { // Eval second definition. TestAll("TypeError", def0 + '; eval("' + def1 + '")'); // Eval both definitions separately. - TestAll("TypeError", 'eval("' + def0 +'"); eval("' + def1 + '")'); + TestAll("TypeError", 'eval("' + def0 +'"); eval("' + def1 + '")'); } diff --git a/test/mjsunit/d8-os.js b/test/mjsunit/d8-os.js index fd6fb774..56403268 100644 --- a/test/mjsunit/d8-os.js +++ b/test/mjsunit/d8-os.js @@ -30,7 +30,7 @@ // implemented on Windows, and even if it were then many of the things // we are calling would not be available. -var TEST_DIR = "d8-os-test-directory-" + ((Math.random() * (1<<30)) | 0); +var TEST_DIR = "/tmp/d8-os-test-directory-" + ((Math.random() * (1<<30)) | 0); function arg_error(str) { @@ -64,7 +64,7 @@ if (this.os && os.system) { os.chdir(TEST_DIR); try { // Check the chdir worked. - os.system('ls', ['../' + TEST_DIR]); + os.system('ls', [TEST_DIR]); // Simple create dir. os.mkdirp("dir"); // Create dir in dir. @@ -144,7 +144,6 @@ if (this.os && os.system) { //} } } finally { - os.chdir(".."); os.system("rm", ["-r", TEST_DIR]); } diff --git a/test/mjsunit/date-parse.js b/test/mjsunit/date-parse.js index a1eef663..b46e39ab 100644 --- a/test/mjsunit/date-parse.js +++ b/test/mjsunit/date-parse.js @@ -286,7 +286,7 @@ for (var i = 0; i < 24 * 365 * 100; i += 150) { // Negative tests. var testCasesNegative = [ 'May 25 2008 1:30 (PM)) UTC', // Bad unmatched ')' after number. - 'May 25 2008 1:30( )AM (PM)', // + 'May 25 2008 1:30( )AM (PM)', // 'May 25 2008 AAA (GMT)']; // Unknown word after number. testCasesNegative.forEach(function (s) { diff --git a/test/mjsunit/debug-compile-event.js b/test/mjsunit/debug-compile-event.js index b00a907a..94dddfa1 100644 --- a/test/mjsunit/debug-compile-event.js +++ b/test/mjsunit/debug-compile-event.js @@ -81,7 +81,7 @@ function listener(event, exec_state, event_data, data) { assertTrue('context' in msg.body.script); // Check that we pick script name from //@ sourceURL, iff present - assertEquals(current_source.indexOf('sourceURL') >= 0 ? + assertEquals(current_source.indexOf('sourceURL') >= 0 ? 'myscript.js' : undefined, event_data.script().name()); } diff --git a/test/mjsunit/debug-evaluate-recursive.js b/test/mjsunit/debug-evaluate-recursive.js index 6ee391b6..f34943e5 100644 --- a/test/mjsunit/debug-evaluate-recursive.js +++ b/test/mjsunit/debug-evaluate-recursive.js @@ -110,7 +110,7 @@ function listener_recurse(event, exec_state, event_data, data) { if (event == Debug.DebugEvent.Break) { break_count++; - + // Call functions with break using the FrameMirror directly. if (break_count == 1) { // First break event evaluates with break enabled. diff --git a/test/mjsunit/debug-handle.js b/test/mjsunit/debug-handle.js index 98875ceb..1582b9f1 100644 --- a/test/mjsunit/debug-handle.js +++ b/test/mjsunit/debug-handle.js @@ -72,7 +72,7 @@ function lookupRequest(exec_state, arguments, success) { // The base part of all lookup requests. var base_request = '"seq":0,"type":"request","command":"lookup"' - + // Generate request with the supplied arguments. var request; if (arguments) { @@ -214,7 +214,7 @@ function listener(event, exec_state, event_data, data) { 'Handle not in the request: ' + handle); count++; } - assertEquals(count, obj.properties.length, + assertEquals(count, obj.properties.length, 'Unexpected number of resolved objects'); diff --git a/test/mjsunit/debug-listbreakpoints.js b/test/mjsunit/debug-listbreakpoints.js index de0114fe..1d4755fd 100644 --- a/test/mjsunit/debug-listbreakpoints.js +++ b/test/mjsunit/debug-listbreakpoints.js @@ -39,7 +39,7 @@ Debug = debug.Debug // below. The test checks for these line numbers. function g() { // line 40 - var x = 5; + var x = 5; var y = 6; var z = 7; }; diff --git a/test/mjsunit/debug-references.js b/test/mjsunit/debug-references.js index ab6c6292..763e354f 100644 --- a/test/mjsunit/debug-references.js +++ b/test/mjsunit/debug-references.js @@ -52,7 +52,7 @@ function testRequest(dcp, arguments, success, count) { } else { request = '{' + base_request + '}' } - + // Process the request and check expectation. var response = safeEval(dcp.processDebugJSONRequest(request)); if (success) { @@ -88,7 +88,7 @@ function listener(event, exec_state, event_data, data) { var response = safeEval(dcp.processDebugJSONRequest(evaluate_point)); assertTrue(response.success, "Evaluation of Point failed"); var handle = response.body.handle; - + // Test some legal references requests. testRequest(dcp, '{"handle":' + handle + ',"type":"referencedBy"}', true); testRequest(dcp, '{"handle":' + handle + ',"type":"constructedBy"}', diff --git a/test/mjsunit/debug-return-value.js b/test/mjsunit/debug-return-value.js index 3982ea91..02d6a7cb 100644 --- a/test/mjsunit/debug-return-value.js +++ b/test/mjsunit/debug-return-value.js @@ -103,12 +103,12 @@ function listener(event, exec_state, event_data, data) { // Position at the end of the function. assertEquals(debugger_source_position + 50, exec_state.frame(0).sourcePosition()); - + // Just about to return from the function. assertTrue(exec_state.frame(0).isAtReturn()) assertEquals(expected_return_value, exec_state.frame(0).returnValue().value()); - + // Check the same using the JSON commands. var dcp = exec_state.debugCommandProcessor(false); var request = '{"seq":0,"type":"request","command":"backtrace"}'; @@ -118,7 +118,7 @@ function listener(event, exec_state, event_data, data) { assertTrue(frames[0].atReturn); assertEquals(expected_return_value, response.lookup(frames[0].returnValue.ref).value); - + listener_complete = true; } } @@ -132,7 +132,7 @@ Debug.setListener(listener); // Four steps from the debugger statement in this function will position us at // the function return. -// 0 1 2 3 4 5 +// 0 1 2 3 4 5 // 0123456789012345678901234567890123456789012345678901 function f(x) {debugger; if (x) { return 1; } else { return 2; } }; diff --git a/test/mjsunit/debug-scopes.js b/test/mjsunit/debug-scopes.js index 40adf5b2..1c23b0bf 100644 --- a/test/mjsunit/debug-scopes.js +++ b/test/mjsunit/debug-scopes.js @@ -418,6 +418,27 @@ with_5(); EndTest(); +// Nested with blocks using existing object in global code. +BeginTest("With 6"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.With, + debug.ScopeType.With, + debug.ScopeType.Global], exec_state); + CheckScopeContent(with_object, 0, exec_state); + CheckScopeContent(with_object, 1, exec_state); + assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().scope(1).scopeObject()); + assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); +}; + +var with_object = {c:3,d:4}; +with(with_object) { + with(with_object) { + debugger; + } +} +EndTest(); + + // Simple closure formed by returning an inner function referering the outer // functions arguments. BeginTest("Closure 1"); @@ -771,6 +792,23 @@ closure_in_with_3(); EndTest(); +BeginTest("Closure inside With 4"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.With, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x: 2}, 0, exec_state); + CheckScopeContent({x: 1}, 1, exec_state); +}; + +with({x:1}) { + (function(x) { + debugger; + })(2); +} +EndTest(); + + // Test global scope. BeginTest("Global"); listener_delegate = function(exec_state) { @@ -875,6 +913,43 @@ catch_block_4(); EndTest(); +// Test catch in global scope. +BeginTest("Catch block 5"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Catch, + debug.ScopeType.Global], exec_state); + CheckScopeContent({e:'Exception'}, 0, exec_state); +}; + +try { + throw 'Exception'; +} catch (e) { + debugger; +} + +EndTest(); + + +// Closure inside catch in global code. +BeginTest("Catch block 6"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Catch, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x: 2}, 0, exec_state); + CheckScopeContent({e:'Exception'}, 1, exec_state); +}; + +try { + throw 'Exception'; +} catch (e) { + (function(x) { + debugger; + })(2); +} +EndTest(); + + assertEquals(begin_test_count, break_count, 'one or more tests did not enter the debugger'); assertEquals(begin_test_count, end_test_count, diff --git a/test/mjsunit/debug-step-2.js b/test/mjsunit/debug-step-2.js new file mode 100644 index 00000000..502b426e --- /dev/null +++ b/test/mjsunit/debug-step-2.js @@ -0,0 +1,89 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-debug-as debug + +// This test tests that full code compiled without debug break slots +// is recompiled with debug break slots when debugging is started. + +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug + +var bp; +var done = false; +var step_count = 0; + +// Debug event listener which steps until the global variable done is true. +function listener(event, exec_state, event_data, data) { + if (event == Debug.DebugEvent.Break) { + if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); + step_count++; + } +}; + +// Set the global variables state to prpare the stepping test. +function prepare_step_test() { + done = false; + step_count = 0; +} + +// Test function to step through. +function f() { + var i = 1; + var j = 2; + done = true; +}; + +prepare_step_test(); +f(); + +// Add the debug event listener. +Debug.setListener(listener); + +bp = Debug.setBreakPoint(f, 1); + +prepare_step_test(); +f(); +assertEquals(4, step_count); +Debug.clearBreakPoint(bp); + +// Set a breakpoint on the first var statement (line 1). +bp = Debug.setBreakPoint(f, 1); + +// Step through the function ensuring that the var statements are hit as well. +prepare_step_test(); +f(); +assertEquals(4, step_count); + +// Clear the breakpoint and check that no stepping happens. +Debug.clearBreakPoint(bp); +prepare_step_test(); +f(); +assertEquals(0, step_count); + +// Get rid of the debug event listener. +Debug.setListener(null); diff --git a/test/mjsunit/debug-stepin-call-function-stub.js b/test/mjsunit/debug-stepin-call-function-stub.js index c5cf8fdf..053b8bfe 100644 --- a/test/mjsunit/debug-stepin-call-function-stub.js +++ b/test/mjsunit/debug-stepin-call-function-stub.js @@ -62,7 +62,7 @@ function listener(event, exec_state, event_data, data) { Debug.setListener(listener); -function g() { +function g() { return "s"; // expected line } @@ -71,7 +71,7 @@ function testFunction() { var s = 1 +f(10); } -function g2() { +function g2() { return "s2"; // expected line } diff --git a/test/mjsunit/debug-stepin-constructor.js b/test/mjsunit/debug-stepin-constructor.js index 6ee33473..5549814a 100644 --- a/test/mjsunit/debug-stepin-constructor.js +++ b/test/mjsunit/debug-stepin-constructor.js @@ -38,7 +38,7 @@ function listener(event, exec_state, event_data, data) { if (exec_state.frameCount() > 1) { exec_state.prepareStep(Debug.StepAction.StepIn); } - + // Test that there is a script. assertTrue(typeof(event_data.func().script()) == 'object'); } diff --git a/test/mjsunit/delete-in-with.js b/test/mjsunit/delete-in-with.js index 1efc18de..cbcfe991 100644 --- a/test/mjsunit/delete-in-with.js +++ b/test/mjsunit/delete-in-with.js @@ -29,6 +29,6 @@ // objects from within 'with' statements. (function(){ var tmp = { x: 12 }; - with (tmp) { assertTrue(delete x); } + with (tmp) { assertTrue(delete x); } assertFalse("x" in tmp); })(); diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js index d7e9de02..81c6cfe8 100644 --- a/test/mjsunit/external-array.js +++ b/test/mjsunit/external-array.js @@ -81,6 +81,19 @@ assertEquals(2.5, get(array, 0)); assertEquals(3.5, get(array, 1)); } +// Test non-number parameters. +var array_with_length_from_non_number = new Int32Array("2"); +assertEquals(2, array_with_length_from_non_number.length); +array_with_length_from_non_number = new Int32Array(undefined); +assertEquals(0, array_with_length_from_non_number.length); +var foo = { valueOf: function() { return 3; } }; +array_with_length_from_non_number = new Int32Array(foo); +assertEquals(3, array_with_length_from_non_number.length); +foo = { toString: function() { return "4"; } }; +array_with_length_from_non_number = new Int32Array(foo); +assertEquals(4, array_with_length_from_non_number.length); + + // Test loads and stores. types = [Array, Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, PixelArray, Float32Array, Float64Array]; diff --git a/test/mjsunit/function-source.js b/test/mjsunit/function-source.js index 75257756..8f2fc226 100644 --- a/test/mjsunit/function-source.js +++ b/test/mjsunit/function-source.js @@ -36,7 +36,7 @@ function f() { } h(); } - + function g() { function h() { assertEquals(Debug.scriptSource(f), Debug.scriptSource(h)); diff --git a/test/mjsunit/fuzz-natives.js b/test/mjsunit/fuzz-natives.js index f8f0a28e..ff6677e6 100644 --- a/test/mjsunit/fuzz-natives.js +++ b/test/mjsunit/fuzz-natives.js @@ -163,6 +163,9 @@ var knownProblems = { "PromoteScheduledException": true, "DeleteHandleScopeExtensions": true, + // Requires integer arguments to be non-negative. + "Apply": true, + // That can only be invoked on Array.prototype. "FinishArrayPrototypeSetup": true, diff --git a/test/mjsunit/get-own-property-descriptor.js b/test/mjsunit/get-own-property-descriptor.js index 79c1fac6..abb24200 100644 --- a/test/mjsunit/get-own-property-descriptor.js +++ b/test/mjsunit/get-own-property-descriptor.js @@ -27,7 +27,7 @@ // This file only tests very simple descriptors that always have // configurable, enumerable, and writable set to true. -// A range of more elaborate tests are performed in +// A range of more elaborate tests are performed in // object-define-property.js function get() { return x; } diff --git a/test/mjsunit/global-deleted-property-keyed.js b/test/mjsunit/global-deleted-property-keyed.js index 1a1d3cb9..dba3a4d4 100644 --- a/test/mjsunit/global-deleted-property-keyed.js +++ b/test/mjsunit/global-deleted-property-keyed.js @@ -33,6 +33,6 @@ var name = "fisk"; natives[name] = name; function foo() { natives[name] + 12; } -for(var i = 0; i < 3; i++) foo(); +for(var i = 0; i < 3; i++) foo(); delete natives[name]; for(var i = 0; i < 3; i++) foo(); diff --git a/test/mjsunit/harmony/block-conflicts.js b/test/mjsunit/harmony/block-conflicts.js new file mode 100644 index 00000000..8d3de6f9 --- /dev/null +++ b/test/mjsunit/harmony/block-conflicts.js @@ -0,0 +1,126 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-block-scoping + +// Test for conflicting variable bindings. + +function CheckException(e) { + var string = e.toString(); + assertTrue(string.indexOf("has already been declared") >= 0 || + string.indexOf("redeclaration") >= 0); return 'Conflict'; +} + + +function TestFunction(s,e) { + try { + return eval("(function(){" + s + ";return " + e + "})")(); + } catch (x) { + return CheckException(x); + } +} + + +function TestBlock(s,e) { + try { + return eval("(function(){ if (true) { " + s + "; }; return " + e + "})")(); + } catch (x) { + return CheckException(x); + } +} + +function TestAll(expected,s,opt_e) { + var e = ""; + var msg = s; + if (opt_e) { e = opt_e; msg += "; " + opt_e; } + assertEquals(expected, TestFunction(s,e), "function:'" + msg + "'"); + assertEquals(expected, TestBlock(s,e), "block:'" + msg + "'"); +} + + +function TestConflict(s) { + TestAll('Conflict', s); + TestAll('Conflict', 'eval("' + s + '")'); +} + + +function TestNoConflict(s) { + TestAll('NoConflict', s, "'NoConflict'"); + TestAll('NoConflict', 'eval("' + s + '")', "'NoConflict'"); +} + +var letbinds = [ "let x", + "let x = 0", + "let x = undefined", + "function x() { }", + "let x = function() {}", + "let x, y", + "let y, x", + ]; +var varbinds = [ "var x", + "var x = 0", + "var x = undefined", + "var x = function() {}", + "var x, y", + "var y, x", + ]; + + +for (var l = 0; l < letbinds.length; ++l) { + // Test conflicting let/var bindings. + for (var v = 0; v < varbinds.length; ++v) { + // Same level. + TestConflict(letbinds[l] +'; ' + varbinds[v]); + TestConflict(varbinds[v] +'; ' + letbinds[l]); + // Different level. + TestConflict(letbinds[l] +'; {' + varbinds[v] + '; }'); + TestConflict('{ ' + varbinds[v] +'; }' + letbinds[l]); + } + + // Test conflicting let/let bindings. + for (var k = 0; k < letbinds.length; ++k) { + // Same level. + TestConflict(letbinds[l] +'; ' + letbinds[k]); + TestConflict(letbinds[k] +'; ' + letbinds[l]); + // Different level. + TestNoConflict(letbinds[l] +'; { ' + letbinds[k] + '; }'); + TestNoConflict('{ ' + letbinds[k] +'; } ' + letbinds[l]); + } + + // Test conflicting parameter/let bindings. + TestConflict('(function (x) { ' + letbinds[l] + '; })()'); +} + +// Test conflicting catch/var bindings. +for (var v = 0; v < varbinds.length; ++v) { + TestConflict('try {} catch (x) { ' + varbinds[v] + '; }'); +} + +// Test conflicting parameter/var bindings. +for (var v = 0; v < varbinds.length; ++v) { + TestConflict('(function (x) { ' + varbinds[v] + '; })()'); +} diff --git a/test/mjsunit/harmony/block-leave.js b/test/mjsunit/harmony/block-leave.js new file mode 100644 index 00000000..73eaf294 --- /dev/null +++ b/test/mjsunit/harmony/block-leave.js @@ -0,0 +1,225 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-block-scoping + +// We want to test the context chain shape. In each of the tests cases +// below, the outer with is to force a runtime lookup of the identifier 'x' +// to actually verify that the inner context has been discarded. A static +// lookup of 'x' might accidentally succeed. + +{ + let x = 2; + L: { + let x = 3; + assertEquals(3, x); + break L; + assertTrue(false); + } + assertEquals(2, x); +} + +do { + let x = 4; + assertEquals(4,x); + { + let x = 5; + assertEquals(5, x); + continue; + assertTrue(false); + } +} while (false); + +var caught = false; +try { + { + let xx = 18; + throw 25; + assertTrue(false); + } +} catch (e) { + caught = true; + assertEquals(25, e); + with ({y:19}) { + assertEquals(19, y); + try { + // NOTE: This checks that the block scope containing xx has been + // removed from the context chain. + xx; + assertTrue(false); // should not reach here + } catch (e2) { + assertTrue(e2 instanceof ReferenceError); + } + } +} +assertTrue(caught); + + +with ({x: 'outer'}) { + label: { + let x = 'inner'; + break label; + } + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + label: { + let x = 'middle'; + { + let x = 'inner'; + break label; + } + } + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + for (var i = 0; i < 10; ++i) { + let x = 'inner' + i; + continue; + } + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + label: for (var i = 0; i < 10; ++i) { + let x = 'middle' + i; + for (var j = 0; j < 10; ++j) { + let x = 'inner' + j; + continue label; + } + } + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + try { + let x = 'inner'; + throw 0; + } catch (e) { + assertEquals('outer', x); + } +} + + +with ({x: 'outer'}) { + try { + let x = 'middle'; + { + let x = 'inner'; + throw 0; + } + } catch (e) { + assertEquals('outer', x); + } +} + + +try { + with ({x: 'outer'}) { + try { + let x = 'inner'; + throw 0; + } finally { + assertEquals('outer', x); + } + } +} catch (e) { + if (e instanceof MjsUnitAssertionError) throw e; +} + + +try { + with ({x: 'outer'}) { + try { + let x = 'middle'; + { + let x = 'inner'; + throw 0; + } + } finally { + assertEquals('outer', x); + } + } +} catch (e) { + if (e instanceof MjsUnitAssertionError) throw e; +} + + +// Verify that the context is correctly set in the stack frame after exiting +// from with. +function f() {} + +with ({x: 'outer'}) { + label: { + let x = 'inner'; + break label; + } + f(); // The context could be restored from the stack after the call. + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + for (var i = 0; i < 10; ++i) { + let x = 'inner'; + continue; + } + f(); + assertEquals('outer', x); +} + + +with ({x: 'outer'}) { + try { + let x = 'inner'; + throw 0; + } catch (e) { + f(); + assertEquals('outer', x); + } +} + + +try { + with ({x: 'outer'}) { + try { + let x = 'inner'; + throw 0; + } finally { + f(); + assertEquals('outer', x); + } + } +} catch (e) { + if (e instanceof MjsUnitAssertionError) throw e; +} diff --git a/test/mjsunit/harmony/block-let-declaration.js b/test/mjsunit/harmony/block-let-declaration.js index 19c943f1..49b63481 100644 --- a/test/mjsunit/harmony/block-let-declaration.js +++ b/test/mjsunit/harmony/block-let-declaration.js @@ -57,11 +57,9 @@ function TestLocalDoesNotThrow(str) { // Unprotected statement TestLocalThrows("if (true) let x;", SyntaxError); -TestLocalThrows("with ({}) let x;", SyntaxError); TestLocalThrows("do let x; while (false)", SyntaxError); TestLocalThrows("while (false) let x;", SyntaxError); TestLocalDoesNotThrow("if (true) var x;"); -TestLocalDoesNotThrow("with ({}) var x;"); TestLocalDoesNotThrow("do var x; while (false)"); TestLocalDoesNotThrow("while (false) var x;"); diff --git a/test/mjsunit/harmony/debug-blockscopes.js b/test/mjsunit/harmony/debug-blockscopes.js index e0df71b2..0230e84b 100644 --- a/test/mjsunit/harmony/debug-blockscopes.js +++ b/test/mjsunit/harmony/debug-blockscopes.js @@ -202,17 +202,15 @@ function local_block_1() { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.Local, + CheckScopeChain([debug.ScopeType.Local, debug.ScopeType.Global], exec_state); CheckScopeContent({}, 0, exec_state); - CheckScopeContent({}, 1, exec_state); }; local_block_1(); EndTest(); -// Local scope with a parameter. +// Simple empty block scope in local scope with a parameter. BeginTest("Local 2"); function local_2(a) { @@ -222,10 +220,9 @@ function local_2(a) { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.Local, + CheckScopeChain([debug.ScopeType.Local, debug.ScopeType.Global], exec_state); - CheckScopeContent({a:1}, 1, exec_state); + CheckScopeContent({a:1}, 0, exec_state); }; local_2(1); EndTest(); @@ -266,6 +263,72 @@ local_4(1, 2); EndTest(); +// Single variable in a block scope. +BeginTest("Local 5"); + +function local_5(a) { + { + let x = 5; + debugger; + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x:5}, 0, exec_state); + CheckScopeContent({a:1}, 1, exec_state); +}; +local_5(1); +EndTest(); + + +// Two variables in a block scope. +BeginTest("Local 6"); + +function local_6(a) { + { + let x = 6; + let y = 7; + debugger; + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x:6,y:7}, 0, exec_state); + CheckScopeContent({a:1}, 1, exec_state); +}; +local_6(1); +EndTest(); + + +// Two variables in a block scope. +BeginTest("Local 7"); + +function local_7(a) { + { + { + let x = 8; + debugger; + } + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x:8}, 0, exec_state); + CheckScopeContent({a:1}, 1, exec_state); +}; +local_7(1); +EndTest(); + + // Single empty with block. BeginTest("With block 1"); @@ -276,8 +339,7 @@ function with_block_1() { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.With, + CheckScopeChain([debug.ScopeType.With, debug.ScopeType.Local, debug.ScopeType.Global], exec_state); CheckScopeContent({}, 0, exec_state); @@ -299,16 +361,13 @@ function with_block_2() { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.With, - debug.ScopeType.Block, + CheckScopeChain([debug.ScopeType.With, debug.ScopeType.With, debug.ScopeType.Local, debug.ScopeType.Global], exec_state); CheckScopeContent({}, 0, exec_state); CheckScopeContent({}, 1, exec_state); CheckScopeContent({}, 2, exec_state); - CheckScopeContent({}, 3, exec_state); }; with_block_2(); EndTest(); @@ -324,12 +383,10 @@ function with_block_3() { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.With, + CheckScopeChain([debug.ScopeType.With, debug.ScopeType.Local, debug.ScopeType.Global], exec_state); - CheckScopeContent({}, 0, exec_state); - CheckScopeContent({a:1,b:2}, 1, exec_state); + CheckScopeContent({a:1,b:2}, 0, exec_state); }; with_block_3(); EndTest(); @@ -347,19 +404,39 @@ function with_block_4() { } listener_delegate = function(exec_state) { - CheckScopeChain([debug.ScopeType.Block, - debug.ScopeType.With, - debug.ScopeType.Block, + CheckScopeChain([debug.ScopeType.With, debug.ScopeType.With, debug.ScopeType.Local, debug.ScopeType.Global], exec_state); - CheckScopeContent({a:2,b:1}, 1, exec_state); - CheckScopeContent({a:1,b:2}, 3, exec_state); + CheckScopeContent({a:2,b:1}, 0, exec_state); + CheckScopeContent({a:1,b:2}, 1, exec_state); }; with_block_4(); EndTest(); +// With block and a block local variable. +BeginTest("With block 5"); + +function with_block_5() { + with({a:1}) { + let a = 2; + debugger; + } +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.With, + debug.ScopeType.Local, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:2}, 0, exec_state); + CheckScopeContent({a:1}, 1, exec_state); +}; +with_block_5(); +EndTest(); + + // Simple closure formed by returning an inner function referering to an outer // block local variable and an outer function's parameter. BeginTest("Closure 1"); diff --git a/test/mjsunit/harmony/proxies.js b/test/mjsunit/harmony/proxies.js index 640033d9..3c4e5f61 100644 --- a/test/mjsunit/harmony/proxies.js +++ b/test/mjsunit/harmony/proxies.js @@ -1,5 +1,3 @@ -// Flags: --harmony-proxies - // Copyright 2008 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -27,16 +25,39 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --harmony-proxies + -// TODO(rossberg): test exception cases. +// TODO(rossberg): for-in for proxies not implemented. +// TODO(rossberg): inheritance from proxies not implemented. +// TODO(rossberg): function proxies as constructors not implemented. + + +// Helper. + +function TestWithProxies(test, handler) { + test(handler, Proxy.create) + test(handler, function(h) {return Proxy.createFunction(h, function() {})}) +} // Getters. function TestGet(handler) { - var o = Proxy.create(handler) - assertEquals(42, o.a) - assertEquals(42, o["b"]) + TestWithProxies(TestGet2, handler) +} + +function TestGet2(handler, create) { + var p = create(handler) + assertEquals(42, p.a) + assertEquals(42, p["b"]) + + // TODO(rossberg): inheritance from proxies not yet implemented. + // var o = Object.create(p, {x: {value: 88}}) + // assertEquals(42, o.a) + // assertEquals(42, o["b"]) + // assertEquals(88, o.x) + // assertEquals(88, o["x"]) } TestGet({ @@ -76,7 +97,11 @@ TestGet(Proxy.create({ function TestGetCall(handler) { - var p = Proxy.create(handler) + TestWithProxies(TestGetCall2, handler) +} + +function TestGetCall2(handler, create) { + var p = create(handler) assertEquals(55, p.f()) assertEquals(55, p.f("unused", "arguments")) assertEquals(55, p.f.call(p)) @@ -139,17 +164,72 @@ TestGetCall(Proxy.create({ })) +function TestGetThrow(handler) { + TestWithProxies(TestGetThrow2, handler) +} + +function TestGetThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ p.a }, "myexn") + assertThrows(function(){ p["b"] }, "myexn") +} + +TestGetThrow({ + get: function(r, k) { throw "myexn" } +}) + +TestGetThrow({ + get: function(r, k) { return this.get2(r, k) }, + get2: function(r, k) { throw "myexn" } +}) + +TestGetThrow({ + getPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestGetThrow({ + getPropertyDescriptor: function(k) { return this.getPropertyDescriptor2(k) }, + getPropertyDescriptor2: function(k) { throw "myexn" } +}) + +TestGetThrow({ + getPropertyDescriptor: function(k) { + return {get value() { throw "myexn" }} + } +}) + +TestGetThrow({ + get: undefined, + getPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestGetThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestGetThrow(Proxy.create({ + get: function(pr, pk) { + return function(r, k) { throw "myexn" } + } +})) + + // Setters. var key var val -function TestSet(handler) { - var o = Proxy.create(handler) - assertEquals(42, o.a = 42) + +function TestSet(handler, create) { + TestWithProxies(TestSet2, handler) +} + +function TestSet2(handler, create) { + var p = create(handler) + assertEquals(42, p.a = 42) assertEquals("a", key) assertEquals(42, val) - assertEquals(43, o["b"] = 43) + assertEquals(43, p["b"] = 43) assertEquals("b", key) assertEquals(43, val) } @@ -225,31 +305,156 @@ TestSet(Proxy.create({ +function TestSetThrow(handler, create) { + TestWithProxies(TestSetThrow2, handler) +} + +function TestSetThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ p.a = 42 }, "myexn") + assertThrows(function(){ p["b"] = 42 }, "myexn") +} + +TestSetThrow({ + set: function(r, k, v) { throw "myexn" } +}) + +TestSetThrow({ + set: function(r, k, v) { return this.set2(r, k, v) }, + set2: function(r, k, v) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" }, + defineProperty: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return {writable: true} }, + defineProperty: function(k, desc) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { throw "myexn" }, + defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, + defineProperty2: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { return {writable: true} }, + defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, + defineProperty2: function(k, desc) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" }, + defineProperty: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { + return {get writable() { return true }} + }, + defineProperty: function(k, desc) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { + return {set: function(v) { throw "myexn" }} + } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" }, + getPropertyDescriptor: function(k) { return {writable: true} }, + defineProperty: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return null }, + getPropertyDescriptor: function(k) { throw "myexn" }, + defineProperty: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return null }, + getPropertyDescriptor: function(k) { return {writable: true} }, + defineProperty: function(k, desc) { throw "myexn" } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return null }, + getPropertyDescriptor: function(k) { + return {get writable() { throw "myexn" }} + }, + defineProperty: function(k, desc) { key = k; val = desc.value } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return null }, + getPropertyDescriptor: function(k) { + return {set: function(v) { throw "myexn" }} + } +}) + +TestSetThrow({ + getOwnPropertyDescriptor: function(k) { return null }, + getPropertyDescriptor: function(k) { return null }, + defineProperty: function(k, desc) { throw "myexn" } +}) + +TestSetThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestSetThrow(Proxy.create({ + get: function(pr, pk) { + return function(r, k, v) { throw "myexn" } + } +})) + + + // Property definition (Object.defineProperty and Object.defineProperties). var key var desc + function TestDefine(handler) { - var o = Proxy.create(handler) - assertEquals(o, Object.defineProperty(o, "a", {value: 44})) + TestWithProxies(TestDefine2, handler) +} + +function TestDefine2(handler, create) { + var p = create(handler) + assertEquals(p, Object.defineProperty(p, "a", {value: 44})) assertEquals("a", key) assertEquals(1, Object.getOwnPropertyNames(desc).length) assertEquals(44, desc.value) - assertEquals(o, Object.defineProperty(o, "b", {value: 45, writable: false})) + assertEquals(p, Object.defineProperty(p, "b", {value: 45, writable: false})) assertEquals("b", key) assertEquals(2, Object.getOwnPropertyNames(desc).length) assertEquals(45, desc.value) assertEquals(false, desc.writable) - assertEquals(o, Object.defineProperty(o, "c", {value: 46, enumerable: false})) + assertEquals(p, Object.defineProperty(p, "c", {value: 46, enumerable: false})) assertEquals("c", key) assertEquals(2, Object.getOwnPropertyNames(desc).length) assertEquals(46, desc.value) assertEquals(false, desc.enumerable) var attributes = {configurable: true, mine: 66, minetoo: 23} - assertEquals(o, Object.defineProperty(o, "d", attributes)) + assertEquals(p, Object.defineProperty(p, "d", attributes)) assertEquals("d", key) // Modifying the attributes object after the fact should have no effect. attributes.configurable = false @@ -260,23 +465,23 @@ function TestDefine(handler) { assertEquals(66, desc.mine) assertEquals(23, desc.minetoo) - assertEquals(o, Object.defineProperty(o, "e", {get: function(){ return 5 }})) + assertEquals(p, Object.defineProperty(p, "e", {get: function(){ return 5 }})) assertEquals("e", key) assertEquals(1, Object.getOwnPropertyNames(desc).length) assertEquals(5, desc.get()) - assertEquals(o, Object.defineProperty(o, "zzz", {})) + assertEquals(p, Object.defineProperty(p, "zzz", {})) assertEquals("zzz", key) assertEquals(0, Object.getOwnPropertyNames(desc).length) -// TODO(rossberg): This test requires [s in proxy] to be implemented first. -// var d = Proxy.create({ +// TODO(rossberg): This test requires for-in on proxies. +// var d = create({ // get: function(r, k) { return (k === "value") ? 77 : void 0 }, // getOwnPropertyNames: function() { return ["value"] } // }) // assertEquals(1, Object.getOwnPropertyNames(d).length) // assertEquals(77, d.value) -// assertEquals(o, Object.defineProperty(o, "p", d)) +// assertEquals(p, Object.defineProperty(p, "p", d)) // assertEquals("p", key) // assertEquals(1, Object.getOwnPropertyNames(desc).length) // assertEquals(77, desc.value) @@ -288,12 +493,15 @@ function TestDefine(handler) { last: {value: 21, configurable: true, mine: "eyes"} } Object.defineProperty(props, "hidden", {value: "hidden", enumerable: false}) - assertEquals(o, Object.defineProperties(o, props)) + assertEquals(p, Object.defineProperties(p, props)) assertEquals("last", key) assertEquals(2, Object.getOwnPropertyNames(desc).length) assertEquals(21, desc.value) assertEquals(true, desc.configurable) assertEquals(undefined, desc.mine) // Arguably a bug in the spec... + + var props = {bla: {get value() { throw "myexn" }}} + assertThrows(function(){ Object.defineProperties(p, props) }, "myexn") } TestDefine({ @@ -312,42 +520,91 @@ TestDefine(Proxy.create({ })) +function TestDefineThrow(handler) { + TestWithProxies(TestDefineThrow2, handler) +} + +function TestDefineThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.defineProperty(p, "a", {value: 44})}, "myexn") + +// TODO(rossberg): These tests require for-in on proxies. +// var d1 = create({ +// get: function(r, k) { throw "myexn" }, +// getOwnPropertyNames: function() { return ["value"] } +// }) +// assertThrows(function(){ Object.defineProperty(p, "p", d1) }, "myexn") +// var d2 = create({ +// get: function(r, k) { return 77 }, +// getOwnPropertyNames: function() { throw "myexn" } +// }) +// assertThrows(function(){ Object.defineProperty(p, "p", d2) }, "myexn") + + var props = {bla: {get value() { throw "otherexn" }}} + assertThrows(function(){ Object.defineProperties(p, props) }, "otherexn") +} + +TestDefineThrow({ + defineProperty: function(k, d) { throw "myexn" } +}) + +TestDefineThrow({ + defineProperty: function(k, d) { return this.defineProperty2(k, d) }, + defineProperty2: function(k, d) { throw "myexn" } +}) + +TestDefineThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestDefineThrow(Proxy.create({ + get: function(pr, pk) { + return function(k, d) { throw "myexn" } + } +})) + + // Property deletion (delete). var key + function TestDelete(handler) { - var o = Proxy.create(handler) - assertEquals(true, delete o.a) + TestWithProxies(TestDelete2, handler) +} + +function TestDelete2(handler, create) { + var p = create(handler) + assertEquals(true, delete p.a) assertEquals("a", key) - assertEquals(true, delete o["b"]) + assertEquals(true, delete p["b"]) assertEquals("b", key) - assertEquals(false, delete o.z1) + assertEquals(false, delete p.z1) assertEquals("z1", key) - assertEquals(false, delete o["z2"]) + assertEquals(false, delete p["z2"]) assertEquals("z2", key); (function() { "use strict" - assertEquals(true, delete o.c) + assertEquals(true, delete p.c) assertEquals("c", key) - assertEquals(true, delete o["d"]) + assertEquals(true, delete p["d"]) assertEquals("d", key) - assertThrows(function() { delete o.z3 }, TypeError) + assertThrows(function(){ delete p.z3 }, TypeError) assertEquals("z3", key) - assertThrows(function() { delete o["z4"] }, TypeError) + assertThrows(function(){ delete p["z4"] }, TypeError) assertEquals("z4", key) })() } TestDelete({ - 'delete': function(k) { key = k; return k < "z" } + delete: function(k) { key = k; return k < "z" } }) TestDelete({ - 'delete': function(k) { return this.delete2(k) }, + delete: function(k) { return this.delete2(k) }, delete2: function(k) { key = k; return k < "z" } }) @@ -358,11 +615,51 @@ TestDelete(Proxy.create({ })) +function TestDeleteThrow(handler) { + TestWithProxies(TestDeleteThrow2, handler) +} + +function TestDeleteThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ delete p.a }, "myexn") + assertThrows(function(){ delete p["b"] }, "myexn"); + + (function() { + "use strict" + assertThrows(function(){ delete p.c }, "myexn") + assertThrows(function(){ delete p["d"] }, "myexn") + })() +} + +TestDeleteThrow({ + delete: function(k) { throw "myexn" } +}) + +TestDeleteThrow({ + delete: function(k) { return this.delete2(k) }, + delete2: function(k) { throw "myexn" } +}) + +TestDeleteThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestDeleteThrow(Proxy.create({ + get: function(pr, pk) { + return function(k) { throw "myexn" } + } +})) + + // Property descriptors (Object.getOwnPropertyDescriptor). function TestDescriptor(handler) { - var o = Proxy.create(handler) + TestWithProxies(TestDescriptor2, handler) +} + +function TestDescriptor2(handler, create) { + var p = create(handler) var descs = [ {configurable: true}, {value: 34, enumerable: true, configurable: true}, @@ -371,18 +668,17 @@ function TestDescriptor(handler) { {get: function() { "get" }, set: function() { "set" }, configurable: true} ] for (var i = 0; i < descs.length; ++i) { - assertEquals(o, Object.defineProperty(o, i, descs[i])) - var desc = Object.getOwnPropertyDescriptor(o, i) - for (p in descs[i]) { + assertEquals(p, Object.defineProperty(p, i, descs[i])) + var desc = Object.getOwnPropertyDescriptor(p, i) + for (prop in descs[i]) { // TODO(rossberg): Ignore user attributes as long as the spec isn't // fixed suitably. - if (p != "mine") assertEquals(descs[i][p], desc[p]) + if (prop != "mine") assertEquals(descs[i][prop], desc[prop]) } - assertEquals(undefined, Object.getOwnPropertyDescriptor(o, "absent")) + assertEquals(undefined, Object.getOwnPropertyDescriptor(p, "absent")) } } - TestDescriptor({ defineProperty: function(k, d) { this["__" + k] = d; return true }, getOwnPropertyDescriptor: function(k) { return this["__" + k] } @@ -397,18 +693,43 @@ TestDescriptor({ }) +function TestDescriptorThrow(handler) { + TestWithProxies(TestDescriptorThrow2, handler) +} + +function TestDescriptorThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.getOwnPropertyDescriptor(p, "a") }, "myexn") +} + +TestDescriptorThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestDescriptorThrow({ + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { throw "myexn" } +}) + + // Comparison. function TestComparison(eq) { - var o1 = Proxy.create({}) - var o2 = Proxy.create({}) - - assertTrue(eq(o1, o1)) - assertTrue(eq(o2, o2)) - assertTrue(!eq(o1, o2)) - assertTrue(!eq(o1, {})) - assertTrue(!eq({}, o2)) + TestWithProxies(TestComparison2, eq) +} + +function TestComparison2(eq, create) { + var p1 = create({}) + var p2 = create({}) + + assertTrue(eq(p1, p1)) + assertTrue(eq(p2, p2)) + assertTrue(!eq(p1, p2)) + assertTrue(!eq(p1, {})) + assertTrue(!eq({}, p2)) assertTrue(!eq({}, {})) } @@ -419,45 +740,61 @@ TestComparison(function(o1, o2) { return !(o1 !== o2) }) -// Type. +// Type (typeof). -assertEquals("object", typeof Proxy.create({})) -assertTrue(typeof Proxy.create({}) == "object") -assertTrue("object" == typeof Proxy.create({})) +function TestTypeof() { + assertEquals("object", typeof Proxy.create({})) + assertTrue(typeof Proxy.create({}) == "object") + assertTrue("object" == typeof Proxy.create({})) -// No function proxies yet. + assertEquals("function", typeof Proxy.createFunction({}, function() {})) + assertTrue(typeof Proxy.createFunction({}, function() {}) == "function") + assertTrue("function" == typeof Proxy.createFunction({}, function() {})) +} + +TestTypeof() // Membership test (in). var key + function TestIn(handler) { - var o = Proxy.create(handler) - assertTrue("a" in o) + TestWithProxies(TestIn2, handler) +} + +function TestIn2(handler, create) { + var p = create(handler) + assertTrue("a" in p) assertEquals("a", key) - assertTrue(99 in o) + assertTrue(99 in p) assertEquals("99", key) - assertFalse("z" in o) + assertFalse("z" in p) assertEquals("z", key) - if ("b" in o) { + assertEquals(2, ("a" in p) ? 2 : 0) + assertEquals(0, !("a" in p) ? 2 : 0) + assertEquals(0, ("zzz" in p) ? 2 : 0) + assertEquals(2, !("zzz" in p) ? 2 : 0) + + if ("b" in p) { } else { assertTrue(false) } assertEquals("b", key) - if ("zz" in o) { + if ("zz" in p) { assertTrue(false) } assertEquals("zz", key) - if (!("c" in o)) { + if (!("c" in p)) { assertTrue(false) } assertEquals("c", key) - if (!("zzz" in o)) { + if (!("zzz" in p)) { } else { assertTrue(false) } @@ -506,17 +843,70 @@ TestIn(Proxy.create({ })) +function TestInThrow(handler) { + TestWithProxies(TestInThrow2, handler) +} + +function TestInThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ return "a" in o }, "myexn") + assertThrows(function(){ return !("a" in o) }, "myexn") + assertThrows(function(){ return ("a" in o) ? 2 : 3 }, "myexn") + assertThrows(function(){ if ("b" in o) {} }, "myexn") + assertThrows(function(){ if (!("b" in o)) {} }, "myexn") + assertThrows(function(){ if ("zzz" in o) {} }, "myexn") +} + +TestInThrow({ + has: function(k) { throw "myexn" } +}) + +TestInThrow({ + has: function(k) { return this.has2(k) }, + has2: function(k) { throw "myexn" } +}) + +TestInThrow({ + getPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestInThrow({ + getPropertyDescriptor: function(k) { return this.getPropertyDescriptor2(k) }, + getPropertyDescriptor2: function(k) { throw "myexn" } +}) + +TestInThrow({ + get: undefined, + getPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestInThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestInThrow(Proxy.create({ + get: function(pr, pk) { + return function(k) { throw "myexn" } + } +})) + + // Own Properties (Object.prototype.hasOwnProperty). var key + function TestHasOwn(handler) { - var o = Proxy.create(handler) - assertTrue(Object.prototype.hasOwnProperty.call(o, "a")) + TestWithProxies(TestHasOwn2, handler) +} + +function TestHasOwn2(handler, create) { + var p = create(handler) + assertTrue(Object.prototype.hasOwnProperty.call(p, "a")) assertEquals("a", key) - assertTrue(Object.prototype.hasOwnProperty.call(o, 99)) + assertTrue(Object.prototype.hasOwnProperty.call(p, 99)) assertEquals("99", key) - assertFalse(Object.prototype.hasOwnProperty.call(o, "z")) + assertFalse(Object.prototype.hasOwnProperty.call(p, "z")) assertEquals("z", key) } @@ -564,6 +954,54 @@ TestHasOwn(Proxy.create({ })) +function TestHasOwnThrow(handler) { + TestWithProxies(TestHasOwnThrow2, handler) +} + +function TestHasOwnThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.prototype.hasOwnProperty.call(p, "a")}, + "myexn") + assertThrows(function(){ Object.prototype.hasOwnProperty.call(p, 99)}, + "myexn") +} + +TestHasOwnThrow({ + hasOwn: function(k) { throw "myexn" } +}) + +TestHasOwnThrow({ + hasOwn: function(k) { return this.hasOwn2(k) }, + hasOwn2: function(k) { throw "myexn" } +}) + +TestHasOwnThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestHasOwnThrow({ + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { throw "myexn" } +}) + +TestHasOwnThrow({ + hasOwn: undefined, + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestHasOwnThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestHasOwnThrow(Proxy.create({ + get: function(pr, pk) { + return function(k) { throw "myexn" } + } +})) + + // Instanceof (instanceof) @@ -573,29 +1011,32 @@ function TestInstanceof() { var p2 = Proxy.create({}, o) var p3 = Proxy.create({}, p2) - var f = function() {} - f.prototype = o + var f0 = function() {} + f0.prototype = o var f1 = function() {} f1.prototype = p1 var f2 = function() {} f2.prototype = p2 assertTrue(o instanceof Object) - assertFalse(o instanceof f) + assertFalse(o instanceof f0) assertFalse(o instanceof f1) assertFalse(o instanceof f2) assertFalse(p1 instanceof Object) - assertFalse(p1 instanceof f) + assertFalse(p1 instanceof f0) assertFalse(p1 instanceof f1) assertFalse(p1 instanceof f2) assertTrue(p2 instanceof Object) - assertTrue(p2 instanceof f) + assertTrue(p2 instanceof f0) assertFalse(p2 instanceof f1) assertFalse(p2 instanceof f2) assertTrue(p3 instanceof Object) - assertTrue(p3 instanceof f) + assertTrue(p3 instanceof f0) assertFalse(p3 instanceof f1) assertTrue(p3 instanceof f2) + + var f = Proxy.createFunction({}, function() {}) + assertTrue(f instanceof Function) } TestInstanceof() @@ -642,6 +1083,11 @@ function TestPrototype() { assertTrue(Object.prototype.isPrototypeOf.call(p2, p3)) assertFalse(Object.prototype.isPrototypeOf.call(p2, p4)) assertFalse(Object.prototype.isPrototypeOf.call(p3, p2)) + + var f = Proxy.createFunction({}, function() {}) + assertSame(Object.getPrototypeOf(f), Function.prototype) + assertTrue(Object.prototype.isPrototypeOf(f)) + assertTrue(Object.prototype.isPrototypeOf.call(Function.prototype, f)) } TestPrototype() @@ -651,8 +1097,12 @@ TestPrototype() // Property names (Object.getOwnPropertyNames, Object.keys). function TestPropertyNames(names, handler) { - var p = Proxy.create(handler) - assertArrayEquals(names, Object.getOwnPropertyNames(p)) + TestWithProxies(TestPropertyNames2, [names, handler]) +} + +function TestPropertyNames2(names_handler, create) { + var p = create(names_handler[1]) + assertArrayEquals(names_handler[0], Object.getOwnPropertyNames(p)) } TestPropertyNames([], { @@ -675,9 +1125,32 @@ TestPropertyNames(["[object Object]"], { }) +function TestPropertyNamesThrow(handler) { + TestWithProxies(TestPropertyNamesThrow2, handler) +} + +function TestPropertyNamesThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.getOwnPropertyNames(p) }, "myexn") +} + +TestPropertyNamesThrow({ + getOwnPropertyNames: function() { throw "myexn" } +}) + +TestPropertyNamesThrow({ + getOwnPropertyNames: function() { return this.getOwnPropertyNames2() }, + getOwnPropertyNames2: function() { throw "myexn" } +}) + + function TestKeys(names, handler) { - var p = Proxy.create(handler) - assertArrayEquals(names, Object.keys(p)) + TestWithProxies(TestKeys2, [names, handler]) +} + +function TestKeys2(names_handler, create) { + var p = create(names_handler[1]) + assertArrayEquals(names_handler[0], Object.keys(p)) } TestKeys([], { @@ -730,10 +1203,71 @@ TestKeys([], { }) +function TestKeysThrow(handler) { + TestWithProxies(TestKeysThrow2, handler) +} + +function TestKeysThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.keys(p) }, "myexn") +} + +TestKeysThrow({ + keys: function() { throw "myexn" } +}) + +TestKeysThrow({ + keys: function() { return this.keys2() }, + keys2: function() { throw "myexn" } +}) + +TestKeysThrow({ + getOwnPropertyNames: function() { throw "myexn" }, + getOwnPropertyDescriptor: function(k) { return true } +}) + +TestKeysThrow({ + getOwnPropertyNames: function() { return [1, 2] }, + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestKeysThrow({ + getOwnPropertyNames: function() { return this.getOwnPropertyNames2() }, + getOwnPropertyNames2: function() { throw "myexn" }, +}) + +TestKeysThrow({ + getOwnPropertyNames: function() { return this.getOwnPropertyNames2() }, + getOwnPropertyNames2: function() { return [1, 2] }, + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { throw "myexn" } +}) + +TestKeysThrow({ + get getOwnPropertyNames() { throw "myexn" } +}) + +TestKeysThrow({ + get getOwnPropertyNames() { + return function() { throw "myexn" } + }, +}) + +TestKeysThrow([], { + get getOwnPropertyNames() { + return function() { return [1, 2] } + }, + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + + // Fixing (Object.freeze, Object.seal, Object.preventExtensions, // Object.isFrozen, Object.isSealed, Object.isExtensible) +// TODO(rossberg): use TestWithProxies to include funciton proxies function TestFix(names, handler) { var proto = {p: 77} var assertFixing = function(o, s, f, e) { @@ -742,44 +1276,44 @@ function TestFix(names, handler) { assertEquals(e, Object.isExtensible(o)) } - var o1 = Proxy.create(handler, proto) - assertFixing(o1, false, false, true) - Object.seal(o1) - assertFixing(o1, true, names.length === 0, false) - assertArrayEquals(names.sort(), Object.getOwnPropertyNames(o1).sort()) + var p1 = Proxy.create(handler, proto) + assertFixing(p1, false, false, true) + Object.seal(p1) + assertFixing(p1, true, names.length === 0, false) + assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p1).sort()) assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), - Object.keys(o1).sort()) - assertEquals(proto, Object.getPrototypeOf(o1)) - assertEquals(77, o1.p) - for (var n in o1) { - var desc = Object.getOwnPropertyDescriptor(o1, n) + Object.keys(p1).sort()) + assertEquals(proto, Object.getPrototypeOf(p1)) + assertEquals(77, p1.p) + for (var n in p1) { + var desc = Object.getOwnPropertyDescriptor(p1, n) if (desc !== undefined) assertFalse(desc.configurable) } - var o2 = Proxy.create(handler, proto) - assertFixing(o2, false, false, true) - Object.freeze(o2) - assertFixing(o2, true, true, false) - assertArrayEquals(names.sort(), Object.getOwnPropertyNames(o2).sort()) + var p2 = Proxy.create(handler, proto) + assertFixing(p2, false, false, true) + Object.freeze(p2) + assertFixing(p2, true, true, false) + assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p2).sort()) assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), - Object.keys(o2).sort()) - assertEquals(proto, Object.getPrototypeOf(o2)) - assertEquals(77, o2.p) - for (var n in o2) { - var desc = Object.getOwnPropertyDescriptor(o2, n) + Object.keys(p2).sort()) + assertEquals(proto, Object.getPrototypeOf(p2)) + assertEquals(77, p2.p) + for (var n in p2) { + var desc = Object.getOwnPropertyDescriptor(p2, n) if (desc !== undefined) assertFalse(desc.writable) if (desc !== undefined) assertFalse(desc.configurable) } - var o3 = Proxy.create(handler, proto) - assertFixing(o3, false, false, true) - Object.preventExtensions(o3) - assertFixing(o3, names.length === 0, names.length === 0, false) - assertArrayEquals(names.sort(), Object.getOwnPropertyNames(o3).sort()) + var p3 = Proxy.create(handler, proto) + assertFixing(p3, false, false, true) + Object.preventExtensions(p3) + assertFixing(p3, names.length === 0, names.length === 0, false) + assertArrayEquals(names.sort(), Object.getOwnPropertyNames(p3).sort()) assertArrayEquals(names.filter(function(x) {return x < "z"}).sort(), - Object.keys(o3).sort()) - assertEquals(proto, Object.getPrototypeOf(o3)) - assertEquals(77, o3.p) + Object.keys(p3).sort()) + assertEquals(proto, Object.getPrototypeOf(p3)) + assertEquals(77, p3.p) } TestFix([], { @@ -814,17 +1348,84 @@ TestFix(["b"], { }) +function TestFixFunction(fix) { + var f1 = Proxy.createFunction({ + fix: function() { return {} } + }, function() {}) + fix(f1) + assertEquals(0, f1.length) + + var f2 = Proxy.createFunction({ + fix: function() { return {length: {value: 3}} } + }, function() {}) + fix(f2) + assertEquals(3, f2.length) + + var f3 = Proxy.createFunction({ + fix: function() { return {length: {value: "huh"}} } + }, function() {}) + fix(f3) + assertEquals(0, f1.length) +} -// String conversion (Object.prototype.toString, Object.prototype.toLocaleString) +TestFixFunction(Object.seal) +TestFixFunction(Object.freeze) +TestFixFunction(Object.preventExtensions) + + +function TestFixThrow(handler) { + TestWithProxies(TestFixThrow2, handler) +} + +function TestFixThrow2(handler) { + var p = Proxy.create(handler, {}) + assertThrows(function(){ Object.seal(p) }, "myexn") + assertThrows(function(){ Object.freeze(p) }, "myexn") + assertThrows(function(){ Object.preventExtensions(p) }, "myexn") +} + +TestFixThrow({ + fix: function() { throw "myexn" } +}) + +TestFixThrow({ + fix: function() { return this.fix2() }, + fix2: function() { throw "myexn" } +}) + +TestFixThrow({ + get fix() { throw "myexn" } +}) + +TestFixThrow({ + get fix() { + return function() { throw "myexn" } + } +}) + + + +// String conversion (Object.prototype.toString, +// Object.prototype.toLocaleString, +// Function.prototype.toString) var key + function TestToString(handler) { - var o = Proxy.create(handler) + var p = Proxy.create(handler) key = "" - assertEquals("[object Object]", Object.prototype.toString.call(o)) + assertEquals("[object Object]", Object.prototype.toString.call(p)) assertEquals("", key) - assertEquals("my_proxy", Object.prototype.toLocaleString.call(o)) + assertEquals("my_proxy", Object.prototype.toLocaleString.call(p)) assertEquals("toString", key) + + var f = Proxy.createFunction(handler, function() {}) + key = "" + assertEquals("[object Function]", Object.prototype.toString.call(f)) + assertEquals("", key) + assertEquals("my_proxy", Object.prototype.toLocaleString.call(f)) + assertEquals("toString", key) + assertDoesNotThrow(function(){ Function.prototype.toString.call(f) }) } TestToString({ @@ -843,12 +1444,50 @@ TestToString(Proxy.create({ })) +function TestToStringThrow(handler) { + var p = Proxy.create(handler) + assertEquals("[object Object]", Object.prototype.toString.call(p)) + assertThrows(function(){ Object.prototype.toLocaleString.call(p) }, "myexn") + + var f = Proxy.createFunction(handler, function() {}) + assertEquals("[object Function]", Object.prototype.toString.call(f)) + assertThrows(function(){ Object.prototype.toLocaleString.call(f) }, "myexn") +} + +TestToStringThrow({ + get: function(r, k) { throw "myexn" } +}) + +TestToStringThrow({ + get: function(r, k) { return function() { throw "myexn" } } +}) + +TestToStringThrow({ + get: function(r, k) { return this.get2(r, k) }, + get2: function(r, k) { throw "myexn" } +}) + +TestToStringThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestToStringThrow(Proxy.create({ + get: function(pr, pk) { + return function(r, k) { throw "myexn" } + } +})) + + // Value conversion (Object.prototype.toValue) function TestValueOf(handler) { - var o = Proxy.create(handler) - assertSame(o, Object.prototype.valueOf.call(o)) + TestWithProxies(TestValueOf2, handler) +} + +function TestValueOf2(handler, create) { + var p = create(handler) + assertSame(p, Object.prototype.valueOf.call(p)) } TestValueOf({}) @@ -858,13 +1497,18 @@ TestValueOf({}) // Enumerability (Object.prototype.propertyIsEnumerable) var key + function TestIsEnumerable(handler) { - var o = Proxy.create(handler) - assertTrue(Object.prototype.propertyIsEnumerable.call(o, "a")) + TestWithProxies(TestIsEnumerable2, handler) +} + +function TestIsEnumerable2(handler, create) { + var p = create(handler) + assertTrue(Object.prototype.propertyIsEnumerable.call(p, "a")) assertEquals("a", key) - assertTrue(Object.prototype.propertyIsEnumerable.call(o, 2)) + assertTrue(Object.prototype.propertyIsEnumerable.call(p, 2)) assertEquals("2", key) - assertFalse(Object.prototype.propertyIsEnumerable.call(o, "z")) + assertFalse(Object.prototype.propertyIsEnumerable.call(p, "z")) assertEquals("z", key) } @@ -896,3 +1540,143 @@ TestIsEnumerable(Proxy.create({ } } })) + + +function TestIsEnumerableThrow(handler) { + TestWithProxies(TestIsEnumerableThrow2, handler) +} + +function TestIsEnumerableThrow2(handler, create) { + var p = create(handler) + assertThrows(function(){ Object.prototype.propertyIsEnumerable.call(p, "a") }, + "myexn") + assertThrows(function(){ Object.prototype.propertyIsEnumerable.call(p, 11) }, + "myexn") +} + +TestIsEnumerableThrow({ + getOwnPropertyDescriptor: function(k) { throw "myexn" } +}) + +TestIsEnumerableThrow({ + getOwnPropertyDescriptor: function(k) { + return this.getOwnPropertyDescriptor2(k) + }, + getOwnPropertyDescriptor2: function(k) { throw "myexn" } +}) + +TestIsEnumerableThrow({ + getOwnPropertyDescriptor: function(k) { + return {get enumerable() { throw "myexn" }, configurable: true} + }, +}) + +TestIsEnumerableThrow(Proxy.create({ + get: function(pr, pk) { throw "myexn" } +})) + +TestIsEnumerableThrow(Proxy.create({ + get: function(pr, pk) { + return function(k) { throw "myexn" } + } +})) + + + +// Calling (call, Function.prototype.call, Function.prototype.apply, +// Function.prototype.bind). + +var global = this +var receiver + +function TestCall(isStrict, callTrap) { + assertEquals(42, callTrap(5, 37)) +// TODO(rossberg): unrelated bug: this does not succeed for optimized code. +// assertEquals(isStrict ? undefined : global, receiver) + + var f = Proxy.createFunction({fix: function() { return {} }}, callTrap) + receiver = 333 + assertEquals(42, f(11, 31)) + assertEquals(isStrict ? undefined : global, receiver) + var o = {} + assertEquals(42, Function.prototype.call.call(f, o, 20, 22)) + assertEquals(o, receiver) + assertEquals(43, Function.prototype.call.call(f, null, 20, 23)) + assertEquals(isStrict ? null : global, receiver) + assertEquals(44, Function.prototype.call.call(f, 2, 21, 23)) + assertEquals(2, receiver.valueOf()) + receiver = 333 + assertEquals(32, Function.prototype.apply.call(f, o, [17, 15])) + assertEquals(o, receiver) + var ff = Function.prototype.bind.call(f, o, 12) + receiver = 333 + assertEquals(42, ff(30)) + assertEquals(o, receiver) + receiver = 333 + assertEquals(32, Function.prototype.apply.call(ff, {}, [20])) + assertEquals(o, receiver) + + Object.freeze(f) + receiver = 333 + assertEquals(42, f(11, 31)) +// TODO(rossberg): unrelated bug: this does not succeed for optimized code. +// assertEquals(isStrict ? undefined : global, receiver) + receiver = 333 + assertEquals(42, Function.prototype.call.call(f, o, 20, 22)) + assertEquals(o, receiver) + receiver = 333 + assertEquals(32, Function.prototype.apply.call(f, o, [17, 15])) + assertEquals(o, receiver) + receiver = 333 + assertEquals(42, ff(30)) + assertEquals(o, receiver) + receiver = 333 + assertEquals(32, Function.prototype.apply.call(ff, {}, [20])) + assertEquals(o, receiver) +} + +TestCall(false, function(x, y) { + receiver = this; return x + y +}) + +TestCall(true, function(x, y) { + "use strict"; + receiver = this; return x + y +}) + +TestCall(false, Proxy.createFunction({}, function(x, y) { + receiver = this; return x + y +})) + +TestCall(true, Proxy.createFunction({}, function(x, y) { + "use strict"; + receiver = this; return x + y +})) + +var p = Proxy.createFunction({fix: function() {return {}}}, function(x, y) { + receiver = this; return x + y +}) +TestCall(false, p) +Object.freeze(p) +TestCall(false, p) + + +function TestCallThrow(callTrap) { + var f = Proxy.createFunction({fix: function() {return {}}}, callTrap) + assertThrows(function(){ f(11) }, "myexn") + assertThrows(function(){ Function.prototype.call.call(f, {}, 2) }, "myexn") + assertThrows(function(){ Function.prototype.apply.call(f, {}, [1]) }, "myexn") + + Object.freeze(f) + assertThrows(function(){ f(11) }, "myexn") + assertThrows(function(){ Function.prototype.call.call(f, {}, 2) }, "myexn") + assertThrows(function(){ Function.prototype.apply.call(f, {}, [1]) }, "myexn") +} + +TestCallThrow(function() { throw "myexn" }) +TestCallThrow(Proxy.createFunction({}, function() { throw "myexn" })) + +var p = Proxy.createFunction( + {fix: function() {return {}}}, function() { throw "myexn" }) +Object.freeze(p) +TestCallThrow(p) diff --git a/test/mjsunit/harmony/weakmaps.js b/test/mjsunit/harmony/weakmaps.js index e43f9167..7b5dcaf0 100644 --- a/test/mjsunit/harmony/weakmaps.js +++ b/test/mjsunit/harmony/weakmaps.js @@ -137,7 +137,11 @@ assertTrue(WeakMap.prototype.set instanceof Function) assertTrue(WeakMap.prototype.get instanceof Function) assertTrue(WeakMap.prototype.has instanceof Function) assertTrue(WeakMap.prototype.delete instanceof Function) + + +// Regression test for WeakMap prototype. assertTrue(WeakMap.prototype.constructor === WeakMap) +assertTrue(Object.getPrototypeOf(WeakMap.prototype) === Object.prototype) // Regression test for issue 1617: The prototype of the WeakMap constructor diff --git a/test/mjsunit/html-string-funcs.js b/test/mjsunit/html-string-funcs.js index 213b7f34..b640639d 100644 --- a/test/mjsunit/html-string-funcs.js +++ b/test/mjsunit/html-string-funcs.js @@ -29,7 +29,7 @@ // HTML. function CheckSimple(f, tag) { assertEquals('<' + tag + '>foo</' + tag + '>', - "foo"[f]().toLowerCase()); + "foo"[f]().toLowerCase()); }; var simple = { big: 'big', blink: 'blink', bold: 'b', fixed: 'tt', italics: 'i', small: 'small', diff --git a/test/mjsunit/in.js b/test/mjsunit/in.js index f98db42f..cca61878 100644 --- a/test/mjsunit/in.js +++ b/test/mjsunit/in.js @@ -86,7 +86,7 @@ a[1] = 2; assertFalse(0 in a); assertTrue(1 in a); assertFalse(2 in a); -assertFalse('0' in a); +assertFalse('0' in a); assertTrue('1' in a); assertFalse('2' in a); assertTrue('toString' in a, "toString"); diff --git a/test/mjsunit/instanceof.js b/test/mjsunit/instanceof.js index 01ea4268..050ef2d9 100644 --- a/test/mjsunit/instanceof.js +++ b/test/mjsunit/instanceof.js @@ -60,10 +60,10 @@ TestChains(); function TestExceptions() { function F() { } - var items = [ 1, new Number(42), - true, + var items = [ 1, new Number(42), + true, 'string', new String('hest'), - {}, [], + {}, [], F, new F(), Object, String ]; diff --git a/test/mjsunit/keyed-storage-extend.js b/test/mjsunit/keyed-storage-extend.js index 04d2f047..d7e157b8 100644 --- a/test/mjsunit/keyed-storage-extend.js +++ b/test/mjsunit/keyed-storage-extend.js @@ -37,7 +37,7 @@ function GrowNamed(o) { } function GrowKeyed(o) { - var names = ['a','b','c','d','e','f']; + var names = ['a','b','c','d','e','f']; var i = 0; o[names[i++]] = i; o[names[i++]] = i; diff --git a/test/mjsunit/mirror-array.js b/test/mjsunit/mirror-array.js index eb8f72a8..92e3913f 100644 --- a/test/mjsunit/mirror-array.js +++ b/test/mjsunit/mirror-array.js @@ -64,7 +64,7 @@ function testArrayMirror(a, names) { assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hierachy'); assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirror hierachy'); assertEquals(mirror.length(), a.length, "Length mismatch"); - + var indexedProperties = mirror.indexedPropertiesFromRange(); assertEquals(indexedProperties.length, a.length); for (var i = 0; i < indexedProperties.length; i++) { @@ -110,7 +110,7 @@ function testArrayMirror(a, names) { var found = false; for (var j = 0; j < fromJSON.properties.length; j++) { if (names[i] == fromJSON.properties[j].name) { - found = true; + found = true; } } assertTrue(found, names[i]) diff --git a/test/mjsunit/mirror-function.js b/test/mjsunit/mirror-function.js index 58aee3da..cda815df 100644 --- a/test/mjsunit/mirror-function.js +++ b/test/mjsunit/mirror-function.js @@ -65,7 +65,7 @@ function testFunctionMirror(f) { assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror); assertTrue(mirror.protoObject() instanceof debug.Mirror); assertTrue(mirror.prototypeObject() instanceof debug.Mirror); - + // Test text representation assertEquals(f.toString(), mirror.toText()); diff --git a/test/mjsunit/mirror-script.js b/test/mjsunit/mirror-script.js index 71561701..1d64ac26 100644 --- a/test/mjsunit/mirror-script.js +++ b/test/mjsunit/mirror-script.js @@ -62,7 +62,7 @@ function testScriptMirror(f, file_name, file_lines, type, compilation_type, if (eval_from_line) { assertEquals(eval_from_line, mirror.evalFromLocation().line); } - + // Parse JSON representation and check. var fromJSON = JSON.parse(json); assertEquals('script', fromJSON.type); diff --git a/test/mjsunit/mirror-unresolved-function.js b/test/mjsunit/mirror-unresolved-function.js index c1fe4a3e..46f22a08 100644 --- a/test/mjsunit/mirror-unresolved-function.js +++ b/test/mjsunit/mirror-unresolved-function.js @@ -64,7 +64,7 @@ assertEquals(void 0, mirror.source()); assertEquals('undefined', mirror.constructorFunction().type()); assertEquals('undefined', mirror.protoObject().type()); assertEquals('undefined', mirror.prototypeObject().type()); - + // Parse JSON representation of unresolved functions and check. var fromJSON = eval('(' + json + ')'); assertEquals('function', fromJSON.type, 'Unexpected mirror type in JSON'); diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index b7b0c774..bae09b4e 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -34,6 +34,10 @@ bugs: FAIL # Fails. regress/regress-1119: FAIL +############################################################################# +# Fails due to r10102 which reverts precise stepping on the 3.6 branch. +debug-step-2: FAIL + ############################################################################## # Too slow in debug mode with --stress-opt compiler/regress-stacktrace-methods: PASS, SKIP if $mode == debug @@ -115,6 +119,9 @@ regress/regress-1132: SKIP ############################################################################## [ $arch == mips ] +# Run those tests, but expect them to time out. +array-sort: PASS || TIMEOUT +mirror-object: PASS || TIMEOUT # Skip long-running tests. compiler/alloc-number: SKIP @@ -141,8 +148,11 @@ regress/regress-634: SKIP regress/regress-create-exception: SKIP regress/regress-3218915: SKIP regress/regress-3247124: SKIP +regress/regress-1132: SKIP +regress/regress-1257: SKIP +regress/regress-91008: SKIP - +############################################################################## [ $isolates ] # d8-os writes temporary files that might interfer with each other when running # in multible threads. Skip this if running with isolates testing. diff --git a/test/mjsunit/no-semicolon.js b/test/mjsunit/no-semicolon.js index fa6ccba8..273ec4bc 100644 --- a/test/mjsunit/no-semicolon.js +++ b/test/mjsunit/no-semicolon.js @@ -30,7 +30,7 @@ function f() { return } -function g() { +function g() { return 4; } @@ -42,4 +42,4 @@ for (var i = 0; i < 10; i++) { break } assertEquals(0, i); for (var i = 0; i < 10; i++) { continue } -assertEquals(10, i);
\ No newline at end of file +assertEquals(10, i); diff --git a/test/mjsunit/object-define-properties.js b/test/mjsunit/object-define-properties.js index 6b3725b3..128df694 100644 --- a/test/mjsunit/object-define-properties.js +++ b/test/mjsunit/object-define-properties.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Tests the Object.defineProperties method - ES 15.2.3.7 -// Note that the internal DefineOwnProperty method is tested through +// Note that the internal DefineOwnProperty method is tested through // object-define-property.js, this file only contains tests specific for // Object.defineProperties. Also note that object-create.js contains // a range of indirect tests on this method since Object.create uses diff --git a/test/mjsunit/object-literal-conversions.js b/test/mjsunit/object-literal-conversions.js index 8540d930..742f814b 100644 --- a/test/mjsunit/object-literal-conversions.js +++ b/test/mjsunit/object-literal-conversions.js @@ -43,4 +43,4 @@ var test6 = { 17.31: function() {}, "17.31": 7 }; assertEquals(7, test5[13]); assertEquals(7, test6[17.31]); -
\ No newline at end of file + diff --git a/test/mjsunit/object-literal-overwrite.js b/test/mjsunit/object-literal-overwrite.js index 5c58a2dd..5a3584df 100644 --- a/test/mjsunit/object-literal-overwrite.js +++ b/test/mjsunit/object-literal-overwrite.js @@ -79,7 +79,7 @@ assertEquals(7, foo7[15]); // Test for the classic code generator. function fun(x) { - var inner = { j: function(x) { return x; }, j: 7 }; + var inner = { j: function(x) { return x; }, j: 7 }; return inner.j; } @@ -115,4 +115,4 @@ function fun3() { var y = fun3(); assertEquals(7, y); -assertEquals(3, glob3);
\ No newline at end of file +assertEquals(3, glob3); diff --git a/test/mjsunit/object-prevent-extensions.js b/test/mjsunit/object-prevent-extensions.js index dc32342c..322a2cb5 100644 --- a/test/mjsunit/object-prevent-extensions.js +++ b/test/mjsunit/object-prevent-extensions.js @@ -33,7 +33,7 @@ var obj1 = {}; assertTrue(Object.isExtensible(obj1)); Object.preventExtensions(obj1); -// Make sure the is_extensible flag is set. +// Make sure the is_extensible flag is set. assertFalse(Object.isExtensible(obj1)); obj1.x = 42; assertEquals(undefined, obj1.x); diff --git a/test/mjsunit/regress/regress-1081309.js b/test/mjsunit/regress/regress-1081309.js index 009ede15..5a6c5241 100644 --- a/test/mjsunit/regress/regress-1081309.js +++ b/test/mjsunit/regress/regress-1081309.js @@ -67,7 +67,7 @@ function listener(event, exec_state, event_data, data) { // The expected backtrace is // 1: g // 0: [anonymous] - + // Get the debug command processor. var dcp = exec_state.debugCommandProcessor(false); diff --git a/test/mjsunit/regress/regress-1092.js b/test/mjsunit/regress/regress-1092.js index 0b29231a..00422cb4 100644 --- a/test/mjsunit/regress/regress-1092.js +++ b/test/mjsunit/regress/regress-1092.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Test that CodeGenerator::EmitKeyedPropertyAssignment for the start +// Test that CodeGenerator::EmitKeyedPropertyAssignment for the start // of an initialization block doesn't normalize the properties of the // JSGlobalProxy. this.w = 0; diff --git a/test/mjsunit/regress/regress-1110.js b/test/mjsunit/regress/regress-1110.js index 204a87ba..43b8d77a 100644 --- a/test/mjsunit/regress/regress-1110.js +++ b/test/mjsunit/regress/regress-1110.js @@ -29,7 +29,7 @@ try { function Crash() { continue;if (Crash) { - } } + } } Crash(); assertTrue(false); } catch (e) { diff --git a/test/mjsunit/regress/regress-1213575.js b/test/mjsunit/regress/regress-1213575.js index 0c3dcc28..9d82064e 100644 --- a/test/mjsunit/regress/regress-1213575.js +++ b/test/mjsunit/regress/regress-1213575.js @@ -33,7 +33,7 @@ this.__defineSetter__('x', function(value) { assertTrue(false); }); var caught = false; try { - eval('const x'); + eval('const x'); } catch(e) { assertTrue(e instanceof TypeError); caught = true; diff --git a/test/mjsunit/regress/regress-98773.js b/test/mjsunit/regress/regress-1215.js index eb24eb5d..93a89f6a 100644 --- a/test/mjsunit/regress/regress-98773.js +++ b/test/mjsunit/regress/regress-1215.js @@ -25,15 +25,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Calling Array.sort on an external array is not supposed to crash. +// Make sure that the "message" property on Error.prototype +// has the following descriptor: +// {writable: true, enumerable: false, and configurable: true} -var array = new Int16Array(23); -array[7] = 7; array[9] = 9; -assertEquals(23, array.length); -assertEquals(7, array[7]); -assertEquals(9, array[9]); +var desc = Object.getOwnPropertyDescriptor(Error.prototype, 'message'); -Array.prototype.sort.call(array); -assertEquals(23, array.length); -assertEquals(7, array[21]); -assertEquals(9, array[22]); +assertEquals(desc.writable, true); +assertEquals(desc.enumerable, false); +assertEquals(desc.configurable, true); diff --git a/test/mjsunit/regress/regress-1447.js b/test/mjsunit/regress/regress-1447.js index 3c64929d..2c1ee591 100644 --- a/test/mjsunit/regress/regress-1447.js +++ b/test/mjsunit/regress/regress-1447.js @@ -27,3 +27,11 @@ [0].forEach(function(){ Object.freeze(Array.prototype.forEach); }); [0].every(function(){ Object.seal(Array.prototype.every); }); + +function testStrict(){ + "use strict"; + [0].forEach(function(){ Object.freeze(Array.prototype.forEach); }); + [0].every(function(){ Object.seal(Array.prototype.every); }); +} + +testStrict(); diff --git a/test/mjsunit/regress/regress-1548.js b/test/mjsunit/regress/regress-1548.js new file mode 100644 index 00000000..074007b9 --- /dev/null +++ b/test/mjsunit/regress/regress-1548.js @@ -0,0 +1,48 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test that the caller and arguments objects are not available on native +// functions. + +function testfn(f) { return [1].map(f)[0]; } +function foo() { return [].map.caller; } +assertEquals(null, testfn(foo)); + +// Try to delete the caller property (to make sure that we can't get to the +// caller accessor on the prototype. +delete Array.prototype.map.caller; +assertEquals(null, testfn(foo)); + +// Redo tests with arguments object. +function testarguments(f) { return [1].map(f)[0]; } +function bar() { return [].map.arguments; } +assertEquals(null, testfn(bar)); + +// Try to delete the arguments property (to make sure that we can't get to the +// caller accessor on the prototype. +delete Array.prototype.map.arguments; +assertEquals(null, testarguments(bar)); diff --git a/test/mjsunit/regress/regress-1639.js b/test/mjsunit/regress/regress-1639.js new file mode 100644 index 00000000..ed68c97d --- /dev/null +++ b/test/mjsunit/regress/regress-1639.js @@ -0,0 +1,85 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-debug-as debug +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug +var breaks = 0; + +function sendCommand(state, cmd) { + // Get the debug command processor in paused state. + var dcp = state.debugCommandProcessor(false); + var request = JSON.stringify(cmd); + var response = dcp.processDebugJSONRequest(request); +} + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + var line = event_data.sourceLineText(); + print('break: ' + line); + + assertEquals(-1, line.indexOf('NOBREAK'), + "should not break on unexpected lines") + assertEquals('BREAK ' + breaks, line.substr(-7)); + breaks++; + sendCommand(exec_state, { + seq: 0, + type: "request", + command: "continue", + arguments: { stepaction: "next" } + }); + } + } catch (e) { + print(e); + } +} + +// Add the debug event listener. +Debug.setListener(listener); + +function a(f) { + if (f) { // NOBREAK: should not break here! + try { + f(); + } catch(e) { + } + } +} // BREAK 2 + +function b() { + c(); // BREAK 0 +} // BREAK 1 + +function c() { + a(); +} + +// Set a break point and call to invoke the debug event listener. +Debug.setBreakPoint(b, 0, 0); +a(b); +// BREAK 3 diff --git a/test/mjsunit/regress/regress-1647.js b/test/mjsunit/regress/regress-1647.js index ab6608c1..a6afcc0b 100644 --- a/test/mjsunit/regress/regress-1647.js +++ b/test/mjsunit/regress/regress-1647.js @@ -40,3 +40,4 @@ for (var i = 0; i < 10; i++) f(); %OptimizeFunctionOnNextCall(f); t.number = 2; f(); + diff --git a/test/mjsunit/regress/regress-1919169.js b/test/mjsunit/regress/regress-1919169.js index 774f2655..a7323128 100644 --- a/test/mjsunit/regress/regress-1919169.js +++ b/test/mjsunit/regress/regress-1919169.js @@ -30,7 +30,7 @@ function test() { var s2 = "s2"; for (var i = 0; i < 2; i++) { // Crashes in round i==1 with IllegalAccess in %StringAdd(x,y) - var res = 1 + s2; + var res = 1 + s2; s2 = 2; } } diff --git a/test/mjsunit/regress/regress-20070207.js b/test/mjsunit/regress/regress-20070207.js index e90b2ec5..b7f7a5cc 100644 --- a/test/mjsunit/regress/regress-20070207.js +++ b/test/mjsunit/regress/regress-20070207.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The following regression test illustrates a problem in using the -// value of setting a property in the arguments object. +// value of setting a property in the arguments object. function f(s) { arguments.length; diff --git a/test/mjsunit/regress/regress-269.js b/test/mjsunit/regress/regress-269.js index 49b24c0b..ce165e0a 100644 --- a/test/mjsunit/regress/regress-269.js +++ b/test/mjsunit/regress/regress-269.js @@ -40,10 +40,10 @@ Debug.setListener(listener); function g() { } - + function f() { debugger; g.apply(null, ['']); } -f()
\ No newline at end of file +f() diff --git a/test/mjsunit/regress/regress-619.js b/test/mjsunit/regress/regress-619.js index 24bdbc18..4d3e66b2 100644 --- a/test/mjsunit/regress/regress-619.js +++ b/test/mjsunit/regress/regress-619.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Tests that Object.defineProperty works correctly on array indices. +// Tests that Object.defineProperty works correctly on array indices. // Please see http://code.google.com/p/v8/issues/detail?id=619 for details. var obj = {}; diff --git a/test/mjsunit/regress/regress-678525.js b/test/mjsunit/regress/regress-678525.js index 5ff9c3d9..11eaf74f 100644 --- a/test/mjsunit/regress/regress-678525.js +++ b/test/mjsunit/regress/regress-678525.js @@ -36,16 +36,16 @@ assertEquals(7, '\7'.charCodeAt(0)); assertEquals(56, '\8'.charCodeAt(0)); assertEquals('\010', '\10'); -assertEquals('\011', '\11'); +assertEquals('\011', '\11'); assertEquals('\012', '\12'); assertEquals('\013', '\13'); assertEquals('\014', '\14'); assertEquals('\015', '\15'); assertEquals('\016', '\16'); assertEquals('\017', '\17'); - + assertEquals('\020', '\20'); -assertEquals('\021', '\21'); +assertEquals('\021', '\21'); assertEquals('\022', '\22'); assertEquals('\023', '\23'); assertEquals('\024', '\24'); @@ -56,4 +56,4 @@ assertEquals('\027', '\27'); assertEquals(73, '\111'.charCodeAt(0)); assertEquals(105, '\151'.charCodeAt(0)); - + diff --git a/test/mjsunit/regress/regress-696.js b/test/mjsunit/regress/regress-696.js index 21977e1c..e443c424 100644 --- a/test/mjsunit/regress/regress-696.js +++ b/test/mjsunit/regress/regress-696.js @@ -28,7 +28,7 @@ // See: http://code.google.com/p/v8/issues/detail?id=696 // Because of the change in dateparser in revision 4557 to support time // only strings in Date.parse we also misleadingly supported strings with non -// leading numbers. +// leading numbers. assertTrue(isNaN(Date.parse('x'))); assertTrue(isNaN(Date.parse('1x'))); diff --git a/test/mjsunit/regress/regress-720.js b/test/mjsunit/regress/regress-720.js index 97e1284e..267b32d0 100644 --- a/test/mjsunit/regress/regress-720.js +++ b/test/mjsunit/regress/regress-720.js @@ -27,7 +27,7 @@ // This regression test is used to ensure that Object.defineProperty // keeps the existing value of the writable flag if none is given -// in the provided descriptor. +// in the provided descriptor. // See: http://code.google.com/p/v8/issues/detail?id=720 var o = {x: 10}; diff --git a/test/mjsunit/regress/regress-747.js b/test/mjsunit/regress/regress-747.js index 6fcc0000..648c3668 100644 --- a/test/mjsunit/regress/regress-747.js +++ b/test/mjsunit/regress/regress-747.js @@ -40,7 +40,7 @@ try { callEval(); } catch (e) { assertUnreachable(); -} +} gc(); gc(); @@ -53,4 +53,4 @@ try { callEval(); } catch (e) { assertUnreachable(); -} +} diff --git a/test/mjsunit/regress/regress-760-1.js b/test/mjsunit/regress/regress-760-1.js index 2e0cee5f..081c9930 100644 --- a/test/mjsunit/regress/regress-760-1.js +++ b/test/mjsunit/regress/regress-760-1.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Check that when valueOf for a String object is overwritten it is called and -// the result used when that object is added with a string. +// the result used when that object is added with a string. // See: http://code.google.com/p/v8/issues/detail?id=760 diff --git a/test/mjsunit/regress/regress-760-2.js b/test/mjsunit/regress/regress-760-2.js index 1b1cbfeb..549ed4ee 100644 --- a/test/mjsunit/regress/regress-760-2.js +++ b/test/mjsunit/regress/regress-760-2.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Check that when valueOf for a String object is overwritten it is called and -// the result used when that object is added with a string. +// the result used when that object is added with a string. // See: http://code.google.com/p/v8/issues/detail?id=760 diff --git a/test/mjsunit/regress/regress-798.js b/test/mjsunit/regress/regress-798.js index ffee5da9..182eb4da 100644 --- a/test/mjsunit/regress/regress-798.js +++ b/test/mjsunit/regress/regress-798.js @@ -32,7 +32,7 @@ x.__defineGetter__("a", function() { try { y.x = 40; } catch (e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } return 40; }); @@ -41,7 +41,7 @@ x.__defineSetter__("a", function(val) { try { y.x = 40; } catch(e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } }); @@ -50,7 +50,7 @@ function getB() { try { y.x = 30; } catch (e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } return 30; } @@ -59,7 +59,7 @@ function setB(val) { try { y.x = 30; } catch(e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } } @@ -72,7 +72,7 @@ var descriptor = { try { y.x = 40; } catch (e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } return 40; }, @@ -80,7 +80,7 @@ var descriptor = { try { y.x = 40; } catch(e) { - assertEquals(3, e.stack.split('\n').length); + assertEquals(3, e.stack.split('\n').length); } } } @@ -88,7 +88,7 @@ var descriptor = { Object.defineProperty(x, 'c', descriptor) // Check that the stack for an exception in a getter and setter produce the -// expected stack height. +// expected stack height. x.a; x.b; x.c; diff --git a/test/mjsunit/regress/regress-918.js b/test/mjsunit/regress/regress-918.js index 4b6ddbac..871e9d9f 100644 --- a/test/mjsunit/regress/regress-918.js +++ b/test/mjsunit/regress/regress-918.js @@ -28,6 +28,6 @@ // Parser should not accept parentheses around labels. // See http://code.google.com/p/v8/issues/detail?id=918 -// The label was parsed as an expression and then tested for being a +// The label was parsed as an expression and then tested for being a // single identifier. This threw away the parentheses. assertThrows("(label):42;"); diff --git a/test/mjsunit/regress/regress-925537.js b/test/mjsunit/regress/regress-925537.js index 11582eaf..d50c5689 100644 --- a/test/mjsunit/regress/regress-925537.js +++ b/test/mjsunit/regress/regress-925537.js @@ -28,8 +28,8 @@ function assertClose(expected, actual) { var delta = 0.00001; if (Math.abs(expected - actual) > delta) { - print('Failure: Expected <' + actual + '> to be close to <' + - expected + '>'); + print('Failure: Expected <' + actual + '> to be close to <' + + expected + '>'); } } diff --git a/test/mjsunit/regress/regress-937896.js b/test/mjsunit/regress/regress-937896.js index e8e5ef21..e7831da3 100644 --- a/test/mjsunit/regress/regress-937896.js +++ b/test/mjsunit/regress/regress-937896.js @@ -41,7 +41,7 @@ function f() { } } } catch (e) { - // Empty. + // Empty. } return 42; } diff --git a/test/mjsunit/regress/regress-99167.js b/test/mjsunit/regress/regress-bind-receiver.js index 5053ae5d..fc83a4e5 100644 --- a/test/mjsunit/regress/regress-99167.js +++ b/test/mjsunit/regress/regress-bind-receiver.js @@ -25,9 +25,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-gc --max-new-space-size=1024 +function strict() { 'use strict'; return this; } +function lenient() { return this; } +var obj = {}; -eval("function Node() { this.a = 1; this.a = 3; }"); -new Node; -for (var i = 0; i < 4; ++i) gc(); -for (var i = 0; i < 100000; ++i) new Node; +assertEquals(true, strict.bind(true)()); +assertEquals(42, strict.bind(42)()); +assertEquals("", strict.bind("")()); +assertEquals(null, strict.bind(null)()); +assertEquals(undefined, strict.bind(undefined)()); +assertEquals(obj, strict.bind(obj)()); + +assertEquals(true, lenient.bind(true)() instanceof Boolean); +assertEquals(true, lenient.bind(42)() instanceof Number); +assertEquals(true, lenient.bind("")() instanceof String); +assertEquals(this, lenient.bind(null)()); +assertEquals(this, lenient.bind(undefined)()); +assertEquals(obj, lenient.bind(obj)()); diff --git a/test/mjsunit/compiler/regress-96989.js b/test/mjsunit/regress/regress-fundecl.js index aedeb243..fddb5895 100644 --- a/test/mjsunit/compiler/regress-96989.js +++ b/test/mjsunit/regress/regress-fundecl.js @@ -25,19 +25,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Flags: --allow-natives-syntax -// Test correct handling of uninitialized const. +// Test hoisting of function declarations in the optimizing +// compiler in case of deoptimization. -function test() { - for (var i = 41; i < 42; i++) { - var c = t ^ i; - } - const t; - return c; +function h(a, b) { + var r = a + b; + function X() { return 42; } + return r + X(); } -for (var i=0; i<10; i++) test(); -%OptimizeFunctionOnNextCall(test); -assertEquals(41, test()); +for (var i = 0; i < 5; i++) h(1,2); + +%OptimizeFunctionOnNextCall(h); + +assertEquals(45, h(1,2)); +assertEquals("foo742", h("foo", 7)); diff --git a/test/mjsunit/setter-on-constructor-prototype.js b/test/mjsunit/setter-on-constructor-prototype.js index d5718f9c..a74f7da7 100644 --- a/test/mjsunit/setter-on-constructor-prototype.js +++ b/test/mjsunit/setter-on-constructor-prototype.js @@ -35,14 +35,14 @@ function RunTest(ensure_fast_case) { if (ensure_fast_case) { %ToFastProperties(C1.prototype); } - + for (var i = 0; i < 10; i++) { var c1 = new C1(); assertEquals("undefined", typeof c1.x); assertEquals(23, c1.y); } - - + + function C2() { this.x = 23; }; @@ -51,14 +51,14 @@ function RunTest(ensure_fast_case) { if (ensure_fast_case) { %ToFastProperties(C2.prototype.__proto__) } - + for (var i = 0; i < 10; i++) { var c2 = new C2(); assertEquals("undefined", typeof c2.x); assertEquals(23, c2.y); } - - + + function C3() { this.x = 23; }; @@ -67,14 +67,14 @@ function RunTest(ensure_fast_case) { if (ensure_fast_case) { %ToFastProperties(C3.prototype); } - + for (var i = 0; i < 10; i++) { var c3 = new C3(); assertEquals("undefined", typeof c3.x); assertEquals(23, c3.y); } - - + + function C4() { this.x = 23; }; @@ -84,14 +84,14 @@ function RunTest(ensure_fast_case) { if (ensure_fast_case) { %ToFastProperties(C4.prototype.__proto__); } - + for (var i = 0; i < 10; i++) { var c4 = new C4(); assertEquals("undefined", typeof c4.x); assertEquals(23, c4.y); } - - + + function D() { this.x = 23; }; @@ -99,7 +99,7 @@ function RunTest(ensure_fast_case) { if (ensure_fast_case) { %ToFastProperties(D.prototype); } - + for (var i = 0; i < 10; i++) { var d = new D(); assertEquals(23, d.x); diff --git a/test/mjsunit/string-compare-alignment.js b/test/mjsunit/string-compare-alignment.js index a291417b..0ae8eb79 100644 --- a/test/mjsunit/string-compare-alignment.js +++ b/test/mjsunit/string-compare-alignment.js @@ -29,8 +29,9 @@ // This situation can arise with sliced strings. This tests for an ARM bug // that was fixed in r554. -var base = "Now is the time for all good men to come to the aid of the party. " + - "Now is the time for all good men to come to the aid of the party." +var base = + "Now is the time for all good men to come to the aid of the party. " + + "Now is the time for all good men to come to the aid of the party." var s1 = base.substring(0, 64); var s2 = base.substring(66, 130); diff --git a/test/mjsunit/string-indexof-1.js b/test/mjsunit/string-indexof-1.js index c5ae4b89..db3623f7 100644 --- a/test/mjsunit/string-indexof-1.js +++ b/test/mjsunit/string-indexof-1.js @@ -63,7 +63,7 @@ assertEquals(1, twoByteString.indexOf("\u0391"), "Alpha"); assertEquals(2, twoByteString.indexOf("\u03a3"), "First Sigma"); assertEquals(3, twoByteString.indexOf("\u03a3",3), "Second Sigma"); assertEquals(4, twoByteString.indexOf("\u0395"), "Epsilon"); -assertEquals(-1, twoByteString.indexOf("\u0392"), "Not beta"); +assertEquals(-1, twoByteString.indexOf("\u0392"), "Not beta"); // Test multi-char pattern assertEquals(0, twoByteString.indexOf("\u039a\u0391"), "lambda Alpha"); @@ -71,7 +71,7 @@ assertEquals(1, twoByteString.indexOf("\u0391\u03a3"), "Alpha Sigma"); assertEquals(2, twoByteString.indexOf("\u03a3\u03a3"), "Sigma Sigma"); assertEquals(3, twoByteString.indexOf("\u03a3\u0395"), "Sigma Epsilon"); -assertEquals(-1, twoByteString.indexOf("\u0391\u03a3\u0395"), +assertEquals(-1, twoByteString.indexOf("\u0391\u03a3\u0395"), "Not Alpha Sigma Epsilon"); //single char pattern diff --git a/test/mjsunit/string-indexof-2.js b/test/mjsunit/string-indexof-2.js index a7c3f600..48db84d2 100644 --- a/test/mjsunit/string-indexof-2.js +++ b/test/mjsunit/string-indexof-2.js @@ -57,10 +57,10 @@ for(var i = 0; i < lipsum.length; i += 3) { var index = -1; do { index = lipsum.indexOf(substring, index + 1); - assertTrue(index != -1, + assertTrue(index != -1, "Lipsum substring " + i + ".." + (i + len-1) + " not found"); - assertEquals(lipsum.substring(index, index + len), substring, - "Wrong lipsum substring found: " + i + ".." + (i + len - 1) + "/" + + assertEquals(lipsum.substring(index, index + len), substring, + "Wrong lipsum substring found: " + i + ".." + (i + len - 1) + "/" + index + ".." + (index + len - 1)); } while (index >= 0 && index < i); assertEquals(i, index, "Lipsum match at " + i + ".." + (i + len - 1)); diff --git a/test/mjsunit/string-replace.js b/test/mjsunit/string-replace.js index 9e4f559e..6b022df3 100644 --- a/test/mjsunit/string-replace.js +++ b/test/mjsunit/string-replace.js @@ -207,3 +207,8 @@ replaceTest("[ab-aabb-ab-b][az-aazz-az-z]", replaceTest("[ab-aabb-ab-b][az-aazz-az-z]", "abaz", /a(.)/g, replacer); + +var str = 'She sells seashells by the seashore.'; +var re = /sh/g; +assertEquals('She sells sea$schells by the sea$schore.', + str.replace(re,"$$" + 'sch')) diff --git a/test/mjsunit/string-slices.js b/test/mjsunit/string-slices.js index f629ca9b..8cc1f81e 100755 --- a/test/mjsunit/string-slices.js +++ b/test/mjsunit/string-slices.js @@ -57,7 +57,7 @@ assertEquals(s, s.substr(-100)); assertEquals('abc', s.substr(-100, 3)); assertEquals(s1, s.substr(-s.length + 1)); -// assertEquals('', s.substr(0, void 0)); // smjs and rhino +// assertEquals('', s.substr(0, void 0)); // smjs and rhino assertEquals('abcdefghijklmn', s.substr(0, void 0)); // kjs and v8 assertEquals('', s.substr(0, null)); assertEquals(s, s.substr(0, String(s.length))); @@ -196,4 +196,4 @@ var b = a.slice(1,-1); assertEquals(a.slice(1,-1), b); externalizeString(a); assertEquals(a.slice(1,-1), b); -*/
\ No newline at end of file +*/ diff --git a/test/mjsunit/string-split.js b/test/mjsunit/string-split.js index bc509451..d8412f0e 100644 --- a/test/mjsunit/string-split.js +++ b/test/mjsunit/string-split.js @@ -68,13 +68,13 @@ assertArrayEquals(["a", "b", "c"], "abc".split(/(?=.)/)); /* "ab".split(/((?=.))/) - * + * * KJS: ,a,,b * SM: a,,b, * IE: a,b * Opera: a,,b * V8: a,,b - * + * * Opera seems to have this right. The others make no sense. */ assertArrayEquals(["a", "", "b"], "ab".split(/((?=.))/)); diff --git a/test/mjsunit/substr.js b/test/mjsunit/substr.js index cffaf94d..cab8b1bf 100755 --- a/test/mjsunit/substr.js +++ b/test/mjsunit/substr.js @@ -55,7 +55,7 @@ assertEquals(s, s.substr(-100)); assertEquals('abc', s.substr(-100, 3)); assertEquals(s1, s.substr(-s.length + 1)); -// assertEquals('', s.substr(0, void 0)); // smjs and rhino +// assertEquals('', s.substr(0, void 0)); // smjs and rhino assertEquals('abcdefghijklmn', s.substr(0, void 0)); // kjs and v8 assertEquals('', s.substr(0, null)); assertEquals(s, s.substr(0, String(s.length))); diff --git a/test/mjsunit/this-property-assignment.js b/test/mjsunit/this-property-assignment.js index c6819996..54c65372 100644 --- a/test/mjsunit/this-property-assignment.js +++ b/test/mjsunit/this-property-assignment.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Tests the handling of multiple assignments to the same property in a +// Tests the handling of multiple assignments to the same property in a // constructor that only has simple this property assignments. function Node() { diff --git a/test/mjsunit/try.js b/test/mjsunit/try.js index 794860a7..86afdf7f 100644 --- a/test/mjsunit/try.js +++ b/test/mjsunit/try.js @@ -250,7 +250,7 @@ function break_from_nested_catch(x) { } catch (o) { x--; } - } + } return x; } @@ -274,7 +274,7 @@ function break_from_nested_finally(x) { x--; } x--; // should not happen - } + } return x; } diff --git a/test/mjsunit/unicode-test.js b/test/mjsunit/unicode-test.js index 59a684e0..66a029a7 100644 --- a/test/mjsunit/unicode-test.js +++ b/test/mjsunit/unicode-test.js @@ -807,7 +807,7 @@ var cyrillic = " * Васильев Л.С. Древний Китай: в 3 т. Т. 3. Период Чжаньго (V–III вв. до н.э.). М.: Восточная литература, 2006. ISBN 502018103X\n" + " * Непомнин О.Е. История Китая: Эпоха Цин. XVII – начало XX века. М.: Восточная литература, 2005. ISBN 5020184004\n"; -var devanagari = +var devanagari = "भारत\n" + "विकिपीडिया, एक मुक्त ज्ञानकोष से\n" + "Jump to: navigation, search\n" + @@ -1417,7 +1417,7 @@ var english = "There are many words of French origin in English, such as competition, art, table, publicity, police, role, routine, machine, force, and many others that have been and are being anglicised; they are now pronounced according to English rules of phonology, rather than French. A large portion of English vocabulary is of French or Oïl language origin, most derived from, or transmitted via, the Anglo-Norman spoken by the upper classes in England for several hundred years after the Norman Conquest.\n"; -var greek = +var greek = "Ελλάδα\n" + "Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια\n" + "Ελληνική Δημοκρατία\n" + diff --git a/test/mjsunit/value-wrapper.js b/test/mjsunit/value-wrapper.js index 88330b44..76e200f3 100644 --- a/test/mjsunit/value-wrapper.js +++ b/test/mjsunit/value-wrapper.js @@ -39,7 +39,7 @@ function RunTests() { assertEquals('object', (42).TypeOfThis()); assertEquals('object', (3.14).TypeOfThis()); } - + for (var i = 0; i < 10; i++) { assertEquals('object', 'xxx'['TypeOfThis']()); assertEquals('object', true['TypeOfThis']()); @@ -47,11 +47,11 @@ function RunTests() { assertEquals('object', (42)['TypeOfThis']()); assertEquals('object', (3.14)['TypeOfThis']()); } - + function CallTypeOfThis(obj) { assertEquals('object', obj.TypeOfThis()); } - + for (var i = 0; i < 10; i++) { CallTypeOfThis('xxx'); CallTypeOfThis(true); @@ -59,7 +59,7 @@ function RunTests() { CallTypeOfThis(42); CallTypeOfThis(3.14); } - + function TestWithWith(obj) { with (obj) { for (var i = 0; i < 10; i++) { @@ -67,13 +67,13 @@ function RunTests() { } } } - + TestWithWith('xxx'); TestWithWith(true); TestWithWith(false); TestWithWith(42); TestWithWith(3.14); - + for (var i = 0; i < 10; i++) { assertEquals('object', true[7]()); assertEquals('object', false[7]()); @@ -100,7 +100,7 @@ function RunTests() { function TypeOfThis() { return typeof this; } -// Test with normal setup of prototype. +// Test with normal setup of prototype. String.prototype.TypeOfThis = TypeOfThis; Boolean.prototype.TypeOfThis = TypeOfThis; Number.prototype.TypeOfThis = TypeOfThis; diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status index f6d69257..3a271309 100644 --- a/test/mozilla/mozilla.status +++ b/test/mozilla/mozilla.status @@ -201,6 +201,10 @@ js1_5/extensions/regress-363258: PASS || FAIL ecma_3/RegExp/regress-85721: PASS || FAIL if $mode == debug +# Test that assumes specific execution time, flaky in debug mode. +js1_5/Array/regress-101964: PASS || FAIL if $mode == debug + + ##################### INCOMPATIBLE TESTS ##################### # This section is for tests that fail in both V8 and JSC. Thus they @@ -245,7 +249,7 @@ ecma_3/Number/15.7.4.7-1: FAIL_OK # toExponential argument restricted to range 0..20 in JSC/V8 ecma_3/Number/15.7.4.6-1: FAIL_OK -#:=== RegExp:=== +#:=== RegExp:=== # We don't match the syntax error message of Mozilla for invalid # RegExp flags. ecma_3/RegExp/15.10.4.1-6: FAIL_OK @@ -578,7 +582,7 @@ js1_5/Regress/regress-352604: FAIL_OK js1_5/Regress/regress-417893: FAIL_OK -# Unsupported use of "[]" as function parameter. We match JSC. +# Unsupported use of "[]" as function parameter. We match JSC. js1_5/Regress/regress-416737-01: FAIL_OK js1_5/Regress/regress-416737-02: FAIL_OK diff --git a/test/preparser/duplicate-parameter.pyt b/test/preparser/duplicate-parameter.pyt new file mode 100644 index 00000000..4dfb7d69 --- /dev/null +++ b/test/preparser/duplicate-parameter.pyt @@ -0,0 +1,90 @@ +# Copyright 2011 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Templatated tests with duplicate parameter names. + +# ---------------------------------------------------------------------- +# Constants and utility functions + +# A template that performs the same strict-mode test in different +# scopes (global scope, function scope, and nested function scope), +# and in non-strict mode too. +def DuplicateParameterTest(name, source): + expectation = "strict_param_dupe" + non_selfstrict = {"selfstrict":"", "id":"selfnormal"} + + Template(name, '"use strict";\n' + source)(non_selfstrict, expectation) + Template(name + '-infunc', + 'function foo() {\n "use strict";\n' + source +'\n}\n')( + non_selfstrict, expectation) + Template(name + '-infunc2', + 'function foo() {\n "use strict";\n function bar() {\n' + + source +'\n }\n}\n')(non_selfstrict, expectation) + + selfstrict = {"selfstrict": "\"use strict\";", "id": "selfstrict"} + nestedstrict = {"selfstrict": "function bar(){\"use strict\";}", + "id": "nestedstrict"} + selfstrictnestedclean = {"selfstrict": """ + "use strict"; + function bar(){} + """, "id": "selfstrictnestedclean"} + selftest = Template(name + '-$id', source) + selftest(selfstrict, expectation) + selftest(selfstrictnestedclean, expectation) + selftest(nestedstrict, None) + selftest(non_selfstrict, None) + + +# ---------------------------------------------------------------------- +# Test templates + +DuplicateParameterTest("dups", """ + function foo(a, a) { $selfstrict } +"""); + +DuplicateParameterTest("dups-apart", """ + function foo(a, b, c, d, e, f, g, h, i, j, k, l, m, n, a) { $selfstrict } +"""); + +DuplicateParameterTest("dups-escaped", """ + function foo(\u0061, b, c, d, e, f, g, h, i, j, k, l, m, n, a) { $selfstrict } +"""); + +DuplicateParameterTest("triples", """ + function foo(a, b, c, d, e, f, g, h, a, i, j, k, l, m, n, a) { $selfstrict } +"""); + +DuplicateParameterTest("escapes", """ + function foo(a, \u0061) { $selfstrict } +"""); + +DuplicateParameterTest("long-names", """ + function foo(arglebargleglopglyfarglebargleglopglyfarglebargleglopglyfa, + arglebargleglopglyfarglebargleglopglyfarglebargleglopglyfa) { + $selfstrict + } +"""); diff --git a/test/preparser/duplicate-property.pyt b/test/preparser/duplicate-property.pyt new file mode 100644 index 00000000..5abf9adb --- /dev/null +++ b/test/preparser/duplicate-property.pyt @@ -0,0 +1,162 @@ +# Copyright 2011 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Tests of duplicate properties in object literals. + +# ---------------------------------------------------------------------- +# Utility functions to generate a number of tests for each property +# name pair. + +def PropertyTest(name, propa, propb, allow_strict = True): + replacement = {"id1": propa, "id2": propb, "name": name} + + # Tests same test in both strict and non-strict context. + def StrictTest(name, source, replacement, expectation): + if (allow_strict): + Template("strict-" + name, + "\"use strict\";\n" + source)(replacement, expectation) + Template(name, source)(replacement, expectation) + + # This one only fails in non-strict context. + if (allow_strict): + Template("strict-$name-data-data", """ + "use strict"; + var o = {$id1: 42, $id2: 42}; + """)(replacement, "strict_duplicate_property") + + Template("$name-data-data", """ + var o = {$id1: 42, $id2: 42}; + """)(replacement, None) + + StrictTest("$name-data-get", """ + var o = {$id1: 42, get $id2(){}}; + """, replacement, "accessor_data_property") + + StrictTest("$name-data-set", """ + var o = {$id1: 42, set $id2(v){}}; + """, replacement, "accessor_data_property") + + StrictTest("$name-get-data", """ + var o = {get $id1(){}, $id2: 42}; + """, replacement, "accessor_data_property") + + StrictTest("$name-set-data", """ + var o = {set $id1(v){}, $id2: 42}; + """, replacement, "accessor_data_property") + + StrictTest("$name-get-get", """ + var o = {get $id1(){}, get $id2(){}}; + """, replacement, "accessor_get_set") + + StrictTest("$name-set-set", """ + var o = {set $id1(v){}, set $id2(v){}}; + """, replacement, "accessor_get_set") + + StrictTest("$name-nested-get", """ + var o = {get $id1(){}, o: {get $id2(){} } }; + """, replacement, None) + + StrictTest("$name-nested-set", """ + var o = {set $id1(){}, o: {set $id2(){} } }; + """, replacement, None) + + +def TestBothWays(name, propa, propb, allow_strict = True): + PropertyTest(name + "-1", propa, propb, allow_strict) + PropertyTest(name + "-2", propb, propa, allow_strict) + +def TestSame(name, prop, allow_strict = True): + PropertyTest(name, prop, prop, allow_strict) + +#----------------------------------------------------------------------- + +# Simple identifier property +TestSame("a", "a") + +# Get/set identifiers +TestSame("get-id", "get") +TestSame("set-id", "set") + +# Number properties +TestSame("0", "0") +TestSame("0.1", "0.1") +TestSame("1.0", "1.0") +TestSame("42.33", "42.33") +TestSame("2^32-2", "4294967294") +TestSame("2^32", "4294967296") +TestSame("2^53", "9007199254740992") +TestSame("Hex20", "0x20") +TestSame("exp10", "1e10") +TestSame("exp20", "1e20") +TestSame("Oct40", "040", False); + + +# String properties +TestSame("str-a", '"a"') +TestSame("str-0", '"0"') +TestSame("str-42", '"42"') +TestSame("str-empty", '""') + +# Keywords +TestSame("if", "if") +TestSame("case", "case") + +# Future reserved keywords +TestSame("public", "public") +TestSame("class", "class") + + +# Test that numbers are converted to string correctly. + +TestBothWays("hex-int", "0x20", "32") +TestBothWays("oct-int", "040", "32", False) # Octals disallowed in strict mode. +TestBothWays("dec-int", "32.00", "32") +TestBothWays("dec-underflow-int", + "32.00000000000000000000000000000000000000001", "32") +TestBothWays("exp-int", "3.2e1", "32") +TestBothWays("exp-int", "3200e-2", "32") +TestBothWays("overflow-inf", "1e2000", "Infinity") +TestBothWays("overflow-inf-exact", "1.797693134862315808e+308", "Infinity") +TestBothWays("non-overflow-inf-exact", "1.797693134862315807e+308", + "1.7976931348623157e+308") +TestBothWays("underflow-0", "1e-2000", "0") +TestBothWays("underflow-0-exact", "2.4703282292062E-324", "0") +TestBothWays("non-underflow-0-exact", "2.4703282292063E-324", "5e-324") +TestBothWays("precission-loss-high", "9007199254740992", "9007199254740993") +TestBothWays("precission-loss-low", "1.9999999999999998", "1.9999999999999997") +TestBothWays("non-canonical-literal-int", "1.0", "1") +TestBothWays("non-canonical-literal-frac", "1.50", "1.5") +TestBothWays("rounding-down", "1.12512512512512452", "1.1251251251251244") +TestBothWays("rounding-up", "1.12512512512512453", "1.1251251251251246") + +TestBothWays("hex-int-str", "0x20", '"32"') +TestBothWays("dec-int-str", "32.00", '"32"') +TestBothWays("exp-int-str", "3.2e1", '"32"') +TestBothWays("overflow-inf-str", "1e2000", '"Infinity"') +TestBothWays("underflow-0-str", "1e-2000", '"0"') +TestBothWays("non-canonical-literal-int-str", "1.0", '"1"') +TestBothWays("non-canonical-literal-frac-str", "1.50", '"1.5"') diff --git a/test/preparser/testcfg.py b/test/preparser/testcfg.py index d900e269..88c06a31 100644 --- a/test/preparser/testcfg.py +++ b/test/preparser/testcfg.py @@ -98,7 +98,6 @@ class PreparserTestConfiguration(test.TestConfiguration): def ParsePythonTestTemplates(self, result, filename, executable, current_path, mode): pathname = join(self.root, filename + ".pyt") - source = open(pathname).read(); def Test(name, source, expectation): throws = None if (expectation is not None): @@ -118,8 +117,7 @@ class PreparserTestConfiguration(test.TestConfiguration): testsource = testsource.replace("$"+key, replacement[key]); Test(testname, testsource, expectation) return MkTest - eval(compile(source, pathname, "exec"), - {"Test": Test, "Template": Template}, {}) + execfile(pathname, {"Test": Test, "Template": Template}) def ListTests(self, current_path, path, mode, variant_flags): executable = 'preparser' @@ -148,7 +146,7 @@ class PreparserTestConfiguration(test.TestConfiguration): filenames.sort() for file in filenames: # Each file as a python source file to be executed in a specially - # perparsed environment (defining the Template and Test functions) + # created environment (defining the Template and Test functions) self.ParsePythonTestTemplates(result, file, executable, current_path, mode) return result |