Skip to content

Commit 557d54b

Browse files
PatrickJSvicb
authored andcommitted
feat(facade): toUpperCase and toLowerCase
1 parent c47902a commit 557d54b

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

modules/angular2/src/facade/lang.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class StringWrapper {
6464
return s.replaceAll(from, replace);
6565
}
6666

67+
static String toUpperCase(String s) {
68+
return s.toUpperCase();
69+
}
70+
71+
static String toLowerCase(String s) {
72+
return s.toLowerCase();
73+
}
74+
6775
static startsWith(String s, String start) {
6876
return s.startsWith(start);
6977
}

modules/angular2/src/facade/lang.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export class StringWrapper {
104104
return s.replace(from, replace);
105105
}
106106

107+
static toUpperCase(s: string): string { return s.toUpperCase(); }
108+
109+
static toLowerCase(s: string): string { return s.toLowerCase(); }
110+
107111
static startsWith(s: string, start: string) { return s.startsWith(start); }
108112

109113
static substring(s: string, start: int, end: int = null) {

modules/angular2/test/facade/lang_spec.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
22

33
import {ListWrapper} from 'angular2/src/facade/collection';
4-
import {isPresent, RegExpWrapper, RegExpMatcherWrapper, CONST_EXPR} from 'angular2/src/facade/lang';
4+
import {isPresent, RegExpWrapper, RegExpMatcherWrapper, StringWrapper, CONST_EXPR} from 'angular2/src/facade/lang';
55

66
export function main() {
77
describe('RegExp', () => {
@@ -20,13 +20,34 @@ export function main() {
2020

2121
expect(indexes).toEqual([1, 4, 8, 9]);
2222
})
23-
});
23+
});
2424

2525
describe('const', () => {
2626
it('should support const expressions both in TS and Dart', () => {
2727
const numbers = CONST_EXPR([1, 2, 3]);
2828
expect(numbers).toEqual([1, 2, 3]);
2929
})
30-
});
30+
});
31+
32+
describe('String', () => {
33+
var upper, lower;
34+
35+
beforeEach(() => {
36+
upper = 'SOMETHING'
37+
lower = 'something';
38+
});
39+
40+
it('should upper case a string', () => {
41+
var str = StringWrapper.toUpperCase(lower);
42+
43+
expect(str).toEqual(upper);
44+
});
45+
46+
it('should lower case a string', () => {
47+
var str = StringWrapper.toLowerCase(upper);
48+
49+
expect(str).toEqual(lower);
50+
});
51+
});
3152

3253
}

0 commit comments

Comments
 (0)