Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: test/cctest/test-decls.cc

Issue 650663003: harmony-scoping: Correct dynamic lookups on a top level. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback + rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/contexts.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 Number::New(CcTest::isolate(), 1)); 706 Number::New(CcTest::isolate(), 1));
707 // TODO(rossberg): All tests should actually be errors in Harmony, 707 // TODO(rossberg): All tests should actually be errors in Harmony,
708 // but we currently do not detect the cases where the first declaration 708 // but we currently do not detect the cases where the first declaration
709 // is not lexical. 709 // is not lexical.
710 context.Check(seconds[j], 710 context.Check(seconds[j],
711 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, 711 i < 2 ? EXPECT_RESULT : EXPECT_ERROR,
712 Number::New(CcTest::isolate(), 2)); 712 Number::New(CcTest::isolate(), 2));
713 } 713 }
714 } 714 }
715 } 715 }
716
717
718 TEST(CrossScriptDynamicLookup) {
719 i::FLAG_harmony_scoping = true;
720
721 HandleScope handle_scope(CcTest::isolate());
722
723 {
724 SimpleContext context;
725 Local<String> undefined_string = String::NewFromUtf8(
726 CcTest::isolate(), "undefined", String::kInternalizedString);
727 Local<String> number_string = String::NewFromUtf8(
728 CcTest::isolate(), "number", String::kInternalizedString);
729
730 context.Check(
731 "function f(o) { with(o) { return x; } }"
732 "function g(o) { with(o) { x = 15; } }"
733 "function h(o) { with(o) { return typeof x; } }",
734 EXPECT_RESULT, Undefined(CcTest::isolate()));
735 context.Check("h({})", EXPECT_RESULT, undefined_string);
736 context.Check(
737 "'use strict';"
738 "let x = 1;"
739 "f({})",
740 EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
741 context.Check(
742 "'use strict';"
743 "g({});"
744 "x",
745 EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
746 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
747 context.Check("h({})", EXPECT_RESULT, number_string);
748 }
749 }
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698