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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: dart/frog/leg/lib/mockimpl.dart
diff --git a/dart/frog/leg/lib/mockimpl.dart b/dart/frog/leg/lib/mockimpl.dart
index 5bea9c40c0e6b6825e70e4b4324899c19d3ac615..1a8e47e852a7149f7e2f55ad685e2852950d8354 100644
--- a/dart/frog/leg/lib/mockimpl.dart
+++ b/dart/frog/leg/lib/mockimpl.dart
@@ -32,15 +32,38 @@ class ReceivePortFactory {
class StringBase {
static String createFromCharCodes(List<int> charCodes) {
- throw "StringBase.createFromCharCodes is not implemented";
+ checkNull(charCodes);
+ if (!isJSArray(charCodes)) {
+ charCodes = new List.from(charCodes);
+ }
+ return Primitives.stringFromCharCodes(charCodes);
}
static String join(List<String> strings, String separator) {
- throw "StringBase.join is not implemented";
+ checkNull(strings);
+ checkNull(separator);
+ if (separator is !String) throw new IllegalArgumentException(separator);
+ var result = "";
+ var first = true;
+ for (var string in strings) {
+ checkNull(string);
+ if (string is !String) throw new IllegalArgumentException(string);
+ if (!first) result += separator; // TODO(ahe): Use string buffer.
+ result += string; // TODO(ahe): Use string buffer.
+ first = false;
+ }
+ return result;
}
static String concatAll(List<String> strings) {
- throw "StringBase.concatAll is not implemented";
+ checkNull(strings);
+ var result = "";
+ for (var string in strings) {
+ checkNull(string);
+ if (string is !String) throw new IllegalArgumentException(string);
+ result += string; // TODO(ahe): Use string buffer.
+ }
+ return result;
}
}

Powered by Google App Engine
This is Rietveld 408576698