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

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

Issue 2789223002: [api] Fix harmony formatting for CompileFunctionInContext
Patch Set: Created 3 years, 8 months 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
« no previous file with comments | « src/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 CHECK_NOT_CAUGHT(env.local(), try_catch, 598 CHECK_NOT_CAUGHT(env.local(), try_catch,
599 "v8::ScriptCompiler::CompileFunctionInContext"); 599 "v8::ScriptCompiler::CompileFunctionInContext");
600 600
601 v8::Local<v8::Function> fun = maybe_fun.ToLocalChecked(); 601 v8::Local<v8::Function> fun = maybe_fun.ToLocalChecked();
602 CHECK(!fun.IsEmpty()); 602 CHECK(!fun.IsEmpty());
603 CHECK(!try_catch.HasCaught()); 603 CHECK(!try_catch.HasCaught());
604 v8::Local<v8::String> result = 604 v8::Local<v8::String> result =
605 fun->ToString(env.local()).ToLocalChecked(); 605 fun->ToString(env.local()).ToLocalChecked();
606 v8::Local<v8::String> expected = v8_str( 606 v8::Local<v8::String> expected = v8_str(
607 "function anonymous(event\n" 607 "function anonymous(event\n"
608 ") {return event\n" 608 ") {\n"
609 "return event\n"
609 "}"); 610 "}");
610 CHECK(expected->Equals(env.local(), result).FromJust()); 611 CHECK(expected->Equals(env.local(), result).FromJust());
611 } 612 }
612 613
613 // With no parameters: 614 // With no parameters:
614 { 615 {
615 v8::ScriptOrigin origin(v8_str("test"), v8_int(17), v8_int(31)); 616 v8::ScriptOrigin origin(v8_str("test"), v8_int(17), v8_int(31));
616 v8::ScriptCompiler::Source script_source(v8_str("return 0"), origin); 617 v8::ScriptCompiler::Source script_source(v8_str("return 0"), origin);
617 618
618 v8::TryCatch try_catch(CcTest::isolate()); 619 v8::TryCatch try_catch(CcTest::isolate());
619 v8::MaybeLocal<v8::Function> maybe_fun = 620 v8::MaybeLocal<v8::Function> maybe_fun =
620 v8::ScriptCompiler::CompileFunctionInContext( 621 v8::ScriptCompiler::CompileFunctionInContext(
621 env.local(), &script_source, 0, nullptr, 0, nullptr); 622 env.local(), &script_source, 0, nullptr, 0, nullptr);
622 623
623 CHECK_NOT_CAUGHT(env.local(), try_catch, 624 CHECK_NOT_CAUGHT(env.local(), try_catch,
624 "v8::ScriptCompiler::CompileFunctionInContext"); 625 "v8::ScriptCompiler::CompileFunctionInContext");
625 626
626 v8::Local<v8::Function> fun = maybe_fun.ToLocalChecked(); 627 v8::Local<v8::Function> fun = maybe_fun.ToLocalChecked();
627 CHECK(!fun.IsEmpty()); 628 CHECK(!fun.IsEmpty());
628 CHECK(!try_catch.HasCaught()); 629 CHECK(!try_catch.HasCaught());
629 v8::Local<v8::String> result = 630 v8::Local<v8::String> result =
630 fun->ToString(env.local()).ToLocalChecked(); 631 fun->ToString(env.local()).ToLocalChecked();
631 v8::Local<v8::String> expected = v8_str( 632 v8::Local<v8::String> expected = v8_str(
632 "function anonymous(\n" 633 "function anonymous(\n"
633 ") {return 0\n" 634 ") {\n"
635 "return 0\n"
634 "}"); 636 "}");
635 CHECK(expected->Equals(env.local(), result).FromJust()); 637 CHECK(expected->Equals(env.local(), result).FromJust());
636 } 638 }
637 } 639 }
638 v8::internal::FLAG_harmony_function_tostring = previous_flag; 640 v8::internal::FLAG_harmony_function_tostring = previous_flag;
639 641
640 #undef CHECK_NOT_CAUGHT 642 #undef CHECK_NOT_CAUGHT
641 } 643 }
642 644
643 #ifdef ENABLE_DISASSEMBLER 645 #ifdef ENABLE_DISASSEMBLER
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 "foo();"); 711 "foo();");
710 Handle<JSFunction> foo = Handle<JSFunction>::cast(GetGlobalProperty("foo")); 712 Handle<JSFunction> foo = Handle<JSFunction>::cast(GetGlobalProperty("foo"));
711 CHECK_EQ(1, foo->feedback_vector()->invocation_count()); 713 CHECK_EQ(1, foo->feedback_vector()->invocation_count());
712 CompileRun("foo()"); 714 CompileRun("foo()");
713 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); 715 CHECK_EQ(2, foo->feedback_vector()->invocation_count());
714 CompileRun("bar()"); 716 CompileRun("bar()");
715 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); 717 CHECK_EQ(2, foo->feedback_vector()->invocation_count());
716 CompileRun("foo(); foo()"); 718 CompileRun("foo(); foo()");
717 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); 719 CHECK_EQ(4, foo->feedback_vector()->invocation_count());
718 } 720 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698