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

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

Issue 2696163002: [debugger] implement inspector-facing API for code coverage. (Closed)
Patch Set: one more shared export 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/mjsunit/code-coverage-ad-hoc.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 6606 matching lines...) Expand 10 before | Expand all | Expand 10 after
6617 reinterpret_cast<void*>(isolate)); 6617 reinterpret_cast<void*>(isolate));
6618 CHECK(!out_of_memory_callback_called); 6618 CHECK(!out_of_memory_callback_called);
6619 // The following allocation fails unless the out-of-memory callback 6619 // The following allocation fails unless the out-of-memory callback
6620 // increases the heap limit. 6620 // increases the heap limit.
6621 int length = 10 * i::MB / i::kPointerSize; 6621 int length = 10 * i::MB / i::kPointerSize;
6622 i_isolate->factory()->NewFixedArray(length, i::TENURED); 6622 i_isolate->factory()->NewFixedArray(length, i::TENURED);
6623 CHECK(out_of_memory_callback_called); 6623 CHECK(out_of_memory_callback_called);
6624 } 6624 }
6625 isolate->Dispose(); 6625 isolate->Dispose();
6626 } 6626 }
6627
6628 TEST(DebugCoverage) {
6629 i::FLAG_always_opt = false;
6630 LocalContext env;
6631 v8::Isolate* isolate = env->GetIsolate();
6632 v8::HandleScope scope(isolate);
6633 v8::debug::Coverage::TogglePrecise(isolate, true);
6634 v8::Local<v8::String> source = v8_str(
6635 "function f() {\n"
6636 "}\n"
6637 "f();\n"
6638 "f();");
6639 CompileRun(source);
6640 v8::debug::Coverage coverage = v8::debug::Coverage::Collect(isolate);
6641 CHECK_EQ(1u, coverage.ScriptCount());
6642 v8::Local<v8::debug::Script> script = coverage.GetScript(0);
6643 CHECK(script->Source()
6644 .ToLocalChecked()
6645 ->Equals(env.local(), source)
6646 .FromMaybe(false));
6647
6648 v8::debug::Coverage::Range range = coverage.GetRange(0);
6649 CHECK_EQ(0, range.Start().GetLineNumber());
6650 CHECK_EQ(0, range.Start().GetColumnNumber());
6651 CHECK_EQ(3, range.End().GetLineNumber());
6652 CHECK_EQ(4, range.End().GetColumnNumber());
6653 CHECK_EQ(1, range.Count());
6654 CHECK_EQ(1u, range.NestedCount());
6655
6656 range = range.GetNested(0);
6657 CHECK_EQ(0, range.Start().GetLineNumber());
6658 CHECK_EQ(0, range.Start().GetColumnNumber());
6659 CHECK_EQ(1, range.End().GetLineNumber());
6660 CHECK_EQ(1, range.End().GetColumnNumber());
6661 CHECK_EQ(2, range.Count());
6662 CHECK_EQ(0, range.NestedCount());
6663 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/code-coverage-ad-hoc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698