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

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

Issue 2700743002: [inspector] extend protocol for code coverage. (Closed)
Patch Set: fix Created 3 years, 10 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/runtime/runtime-debug.cc ('k') | test/inspector/runtime/coverage.js » ('j') | 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 6619 matching lines...) Expand 10 before | Expand all | Expand 10 after
6630 LocalContext env; 6630 LocalContext env;
6631 v8::Isolate* isolate = env->GetIsolate(); 6631 v8::Isolate* isolate = env->GetIsolate();
6632 v8::HandleScope scope(isolate); 6632 v8::HandleScope scope(isolate);
6633 v8::debug::Coverage::TogglePrecise(isolate, true); 6633 v8::debug::Coverage::TogglePrecise(isolate, true);
6634 v8::Local<v8::String> source = v8_str( 6634 v8::Local<v8::String> source = v8_str(
6635 "function f() {\n" 6635 "function f() {\n"
6636 "}\n" 6636 "}\n"
6637 "f();\n" 6637 "f();\n"
6638 "f();"); 6638 "f();");
6639 CompileRun(source); 6639 CompileRun(source);
6640 v8::debug::Coverage coverage = v8::debug::Coverage::Collect(isolate); 6640 v8::debug::Coverage coverage = v8::debug::Coverage::Collect(isolate, false);
6641 CHECK_EQ(1u, coverage.ScriptCount()); 6641 CHECK_EQ(1u, coverage.ScriptCount());
6642 v8::Local<v8::debug::Script> script = coverage.GetScript(0); 6642 v8::debug::Coverage::ScriptData script_data = coverage.GetScriptData(0);
6643 v8::Local<v8::debug::Script> script = script_data.GetScript();
6643 CHECK(script->Source() 6644 CHECK(script->Source()
6644 .ToLocalChecked() 6645 .ToLocalChecked()
6645 ->Equals(env.local(), source) 6646 ->Equals(env.local(), source)
6646 .FromMaybe(false)); 6647 .FromMaybe(false));
6647 6648
6648 v8::debug::Coverage::Range range = coverage.GetRange(0); 6649 CHECK_EQ(2u, script_data.FunctionCount());
6649 CHECK_EQ(0, range.Start().GetLineNumber()); 6650 v8::debug::Coverage::FunctionData function_data =
6650 CHECK_EQ(0, range.Start().GetColumnNumber()); 6651 script_data.GetFunctionData(0);
6651 CHECK_EQ(3, range.End().GetLineNumber()); 6652 CHECK_EQ(0, function_data.Start().GetLineNumber());
6652 CHECK_EQ(4, range.End().GetColumnNumber()); 6653 CHECK_EQ(0, function_data.Start().GetColumnNumber());
6653 CHECK_EQ(1, range.Count()); 6654 CHECK_EQ(3, function_data.End().GetLineNumber());
6654 CHECK_EQ(1u, range.NestedCount()); 6655 CHECK_EQ(4, function_data.End().GetColumnNumber());
6656 CHECK_EQ(1, function_data.Count());
6655 6657
6656 range = range.GetNested(0); 6658 function_data = script_data.GetFunctionData(1);
6657 CHECK_EQ(0, range.Start().GetLineNumber()); 6659 CHECK_EQ(0, function_data.Start().GetLineNumber());
6658 CHECK_EQ(0, range.Start().GetColumnNumber()); 6660 CHECK_EQ(0, function_data.Start().GetColumnNumber());
6659 CHECK_EQ(1, range.End().GetLineNumber()); 6661 CHECK_EQ(1, function_data.End().GetLineNumber());
6660 CHECK_EQ(1, range.End().GetColumnNumber()); 6662 CHECK_EQ(1, function_data.End().GetColumnNumber());
6661 CHECK_EQ(2, range.Count()); 6663 CHECK_EQ(2, function_data.Count());
6662 CHECK_EQ(0, range.NestedCount());
6663 } 6664 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/inspector/runtime/coverage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698