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

Unified Diff: dart/frog/leg/lib/mock.dart

Issue 9420001: Various mocks and tweaks to reduce cancels in Leg. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« no previous file with comments | « dart/frog/leg/lib/coreimpl.dart ('k') | dart/frog/leg/lib/mockimpl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/lib/mock.dart
diff --git a/dart/frog/leg/lib/mock.dart b/dart/frog/leg/lib/mock.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d05bf002befd9b5ec00c43ecbcbb84ba42d58f88
--- /dev/null
+++ b/dart/frog/leg/lib/mock.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2012, 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.
+
+// Mocks of things that Leg cannot read directly.
+
+// TODO(ahe): Remove this file.
+
+interface Exception default ExceptionImplementation {
+ const Exception([var msg]);
+}
+class IndexOutOfRangeException implements Exception {}
+class IllegalAccessException implements Exception {}
+class ClosureArgumentMismatchException implements Exception {}
+class ObjectNotClosureException implements Exception {}
+class IllegalArgumentException implements Exception {}
+class OutOfMemoryException implements Exception {}
+class StackOverflowException implements Exception {}
+class BadNumberFormatException implements Exception {}
+class WrongArgumentCountException implements Exception {}
+class NullPointerException implements Exception {}
+class NoMoreElementsException implements Exception {}
+class EmptyQueueException implements Exception {}
+class UnsupportedOperationException implements Exception {}
+class NotImplementedException implements Exception {}
+class IllegalJSRegExpException implements Exception {}
+class IntegerDivisionByZeroException implements Exception {}
+
+class AssertionError {}
+class TypeError extends AssertionError {}
+class FallThroughError {}
+
+// TODO(ahe): VM specfic exception?
+class InternalError {}
+
+// TODO(ahe): VM specfic exception?
+class StaticResolutionException implements Exception {}
+
+class NoSuchMethodException implements Exception {
+ Object receiver;
+ String name;
+ List args;
+ NoSuchMethodException(Object this.receiver, String this.name, List this.args);
+ String toString() {
+ return "NoSuchMethodException - receiver: '$receiver'" +
+ "function name: '$name' arguments: [$args]";
+ }
+}
+
+class List<E> implements Iterable<E> {
+ factory List([int length]) => Primitives.newList(length);
+ factory List.from(Iterable<E> other) {
+ throw 'List.from is not implemented';
+ }
+}
+
+class Stopwatch {
+ double startMs;
+ double elapsedMs;
+
+ Stopwatch() {
+ elapsedMs = 0.0;
+ }
+
+ void start() {
+ if (startMs == null) {
+ startMs = Primitives.dateNow();
+ }
+ }
+
+ void stop() {
+ if (startMs == null) return;
+ elapsedMs += Primitives.dateNow() - startMs;
+ startMs = null;
+ }
+
+ void reset() {
+ elapsedMs = 0.0;
+ if (startMs == null) return;
+ startMs = Primitives.dateNow();
+ }
+
+ int elapsed() {
+ return elapsedInMs();
+ }
+
+ int elapsedInUs() {
+ return elapsedInMs() * 1000;
+ }
+
+ int elapsedInMs() {
+ if (startMs == null) {
+ return Primitives.mathFloor(elapsedMs);
+ } else {
+ return Primitives.mathFloor(elapsedMs + (Primitives.dateNow() - startMs));
+ }
+ }
+
+ int frequency() {
+ return 1000;
+ }
+}
+
+void assert(condition) {}
« no previous file with comments | « dart/frog/leg/lib/coreimpl.dart ('k') | dart/frog/leg/lib/mockimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698