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

Unified Diff: runtime/observatory/test/caching_test.dart

Issue 959043003: Build script views programmatically. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/test/caching_test.dart
diff --git a/runtime/observatory/test/caching_test.dart b/runtime/observatory/test/caching_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dacfb18ec9ed8d779e1fbb4eb8fa82b954ac2b46
--- /dev/null
+++ b/runtime/observatory/test/caching_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// If caching is working properly, the coverage data will go into the same
+// Script object from which we requested coverage data, instead of a new
+// Script object.
+
+library caching_test;
+
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+import 'test_helper.dart';
+import 'dart:async';
+
+script() {
+ print("This executed");
+}
+
+hasSomeCoverageData(Script script) {
+ for (var line in script.lines) {
+ if (line.hits != null) return true;
+ }
+ return false;
+}
+
+var tests = [
+(Isolate isolate) async {
+ Library lib = await isolate.rootLib.load();
+ Script script = await lib.scripts.single.load();
+ expect(hasSomeCoverageData(script), isFalse);
+ Script script2 = await script.refreshCoverage();
+ expect(identical(script, script2), isTrue);
+ expect(hasSomeCoverageData(script), isTrue);
+},
+
+];
+
+main(args) => runIsolateTests(args, tests, testeeBefore: script);

Powered by Google App Engine
This is Rietveld 408576698