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

Side by Side Diff: dart/frog/leg/lib/mockimpl.dart

Issue 9355032: Implement Strings API. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Mocks of classes and interfaces that Leg cannot read directly. 5 // Mocks of classes and interfaces that Leg cannot read directly.
6 6
7 // TODO(ahe): Remove this file. 7 // TODO(ahe): Remove this file.
8 8
9 class JSSyntaxRegExp implements RegExp { 9 class JSSyntaxRegExp implements RegExp {
10 JSSyntaxRegExp(String pattern, 10 JSSyntaxRegExp(String pattern,
(...skipping 14 matching lines...) Expand all
25 throw 'factory ReceivePort is not implemented'; 25 throw 'factory ReceivePort is not implemented';
26 } 26 }
27 27
28 factory ReceivePort.singleShot() { 28 factory ReceivePort.singleShot() {
29 throw 'factory ReceivePort.singleShot is not implemented'; 29 throw 'factory ReceivePort.singleShot is not implemented';
30 } 30 }
31 } 31 }
32 32
33 class StringBase { 33 class StringBase {
34 static String createFromCharCodes(List<int> charCodes) { 34 static String createFromCharCodes(List<int> charCodes) {
35 throw "StringBase.createFromCharCodes is not implemented"; 35 checkNull(charCodes);
36 if (!isJSArray(charCodes)) {
37 charCodes = new List.from(charCodes);
38 }
39 return Primitives.stringFromCharCodes(charCodes);
36 } 40 }
37 41
38 static String join(List<String> strings, String separator) { 42 static String join(List<String> strings, String separator) {
39 throw "StringBase.join is not implemented"; 43 checkNull(strings);
44 checkNull(separator);
45 if (separator is !String) throw new IllegalArgumentException(separator);
46 var result = "";
47 var first = true;
48 for (var string in strings) {
49 checkNull(string);
50 if (string is !String) throw new IllegalArgumentException(string);
51 if (!first) result += separator; // TODO(ahe): Use string buffer.
52 result += string; // TODO(ahe): Use string buffer.
53 first = false;
54 }
55 return result;
40 } 56 }
41 57
42 static String concatAll(List<String> strings) { 58 static String concatAll(List<String> strings) {
43 throw "StringBase.concatAll is not implemented"; 59 checkNull(strings);
60 var result = "";
61 for (var string in strings) {
62 checkNull(string);
63 if (string is !String) throw new IllegalArgumentException(string);
64 result += string; // TODO(ahe): Use string buffer.
65 }
66 return result;
44 } 67 }
45 } 68 }
46 69
47 class TimeZoneImplementation implements TimeZone { 70 class TimeZoneImplementation implements TimeZone {
48 const TimeZoneImplementation.utc() : isUtc = true; 71 const TimeZoneImplementation.utc() : isUtc = true;
49 TimeZoneImplementation.local() : isUtc = false; 72 TimeZoneImplementation.local() : isUtc = false;
50 73
51 bool operator ==(Object other) { 74 bool operator ==(Object other) {
52 if (!(other is TimeZoneImplementation)) return false; 75 if (!(other is TimeZoneImplementation)) return false;
53 return isUtc == other.isUtc; 76 return isUtc == other.isUtc;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 factory List([int length]) => Primitives.newList(length); 454 factory List([int length]) => Primitives.newList(length);
432 factory List.from(Iterable<E> other) { 455 factory List.from(Iterable<E> other) {
433 List<E> result = new List<E>(); 456 List<E> result = new List<E>();
434 Iterator<E> iterator = other.iterator(); 457 Iterator<E> iterator = other.iterator();
435 while (iterator.hasNext()) { 458 while (iterator.hasNext()) {
436 result.add(iterator.next()); 459 result.add(iterator.next());
437 } 460 }
438 return result; 461 return result;
439 } 462 }
440 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698