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

Unified Diff: tests/lib/i18n/intl_message_test.dart

Issue 10535087: Changes to the i18n messages so that they are invoked as (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « lib/i18n/intl_message.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/i18n/intl_message_test.dart
===================================================================
--- tests/lib/i18n/intl_message_test.dart (revision 8458)
+++ tests/lib/i18n/intl_message_test.dart (working copy)
@@ -13,37 +13,67 @@
* Tests the MessageFormat library in dart.
*/
+class Person {
+ String firstName, lastName;
+ Person(this.firstName, this.lastName);
+}
+
main() {
+ Intl intl = new Intl();
+
test('Trivial Message', () {
- msg_format() => new IntlMessage('Hello, world!',
+ hello() => intl.message('Hello, world!',
desc: 'hello world string');
+ expect(hello(), equals('Hello, world!'));
});
- //expect(msg_format(), 'Hello, world!');
- test('One num', () {
- msg_format(number) => new IntlMessage('Your lucky number is $number',
+ test('Message with one parameter', () {
+ lucky(number) => intl.message('Your lucky number is $number',
desc: 'number str', examples: {'number': 2});
+ expect(lucky(3), equals('Your lucky number is 3'));
});
- //expect(msg_format(3), 'Your lucky number is 3');
- test('Message formatting', () {
- msg_format(number) => new IntlMessage(
+ test('Message with multiple plural cases (whole message)', () {
+ emails(number) => intl.message(
Intl.plural(number,
{'0': 'There are no emails left.',
'1': 'There is one email left.',
'other': 'There are $number emails left.'}),
desc: 'Message telling user how many emails will be sent.',
examples: {'number': 32});
+ expect(emails(5), equals('There are 5 emails left.'));
+ expect(emails(0), equals('There are no emails left.'));
+ expect(emails(1), equals('There is one email left.'));
});
- // TODO(efortuna): Uncomment when functioning correctly.
- //expect(msg_format(5), '5 emails will be sent.');
-
- test('Message formatting with dictionary', () {
- msg_format(dict) => new IntlMessage(
+
+ test('Message with multiple plural cases (partial message)', () {
+ emails(number) => intl.message(
+ "There ${Intl.plural(number,
+ {'0': 'are',
+ '1': 'is',
+ 'other': 'are'})} $number messages left.",
+ desc: 'Message telling user how many emails will be sent.',
+ examples: {'number': 32});
+ expect(emails(5), equals('There are 5 messages left.'));
+ expect(emails(0), equals('There are 0 messages left.'));
+ expect(emails(1), equals('There is 1 messages left.'));
+ });
+
+ test('Message with dictionary parameter', () {
+ hello(dict) => intl.message(
"Hello, my name is ${dict['first']} ${dict['last']}",
- desc: "States a person's name.",
- examples: {'first': 'Ford', 'last': 'Prefect'});
+ desc: "States a person's name.",
+ examples: {'first': 'Ford', 'last': 'Prefect'});
+ expect(hello({'first' : 'Ford', 'last' : 'Prefect'}),
+ equals('Hello, my name is Ford Prefect'));
});
- //expect(msg_format({'first' : 'Ford', 'last' : 'Prefect'),
- // 'Hello, my name is Ford Prefect');
+
+ test('Message with object parameter', () {
+ hello(person) => intl.message(
+ "Hello, my name is ${person.firstName} ${person.lastName}.",
+ desc: "States a person's name.",
+ examples: {'first': 'Ford', 'last' : 'Prefect'});
+ var ford = new Person('Ford', 'Prefect');
+ expect(hello(ford), equals('Hello, my name is Ford Prefect.'));
+ });
}
« no previous file with comments | « lib/i18n/intl_message.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698