Chromium Code Reviews| Index: pkg/intl/test/intl_message_test.dart |
| diff --git a/pkg/intl/test/intl_message_test.dart b/pkg/intl/test/intl_message_test.dart |
| index f8bcd5e32b29d074d70e968e655e0346ba8121ac..38080957dc7a30b410efbc70e9b918de9e820488 100644 |
| --- a/pkg/intl/test/intl_message_test.dart |
| +++ b/pkg/intl/test/intl_message_test.dart |
| @@ -2,13 +2,18 @@ |
| // 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. |
| +/** |
| + * Tests the Intl.message facility in dart with no localization, so we |
| + * expect it to just return the same strings it was given, with parameter |
| + * substitution, pluralization, and so forth. |
| + */ |
| library intl_message_test; |
| -import '../lib/intl.dart'; |
| -import '../../../pkg/unittest/lib/unittest.dart'; |
| -import '../lib/message_lookup_local.dart'; |
| - |
| -/** Tests the MessageFormat library in dart. */ |
| +import 'package:intl/intl.dart'; |
| +import 'package:intl/src/intl_helpers.dart'; |
| +import 'package:unittest/unittest.dart'; |
| +import 'package:intl/message_lookup_by_library.dart'; |
| +import 'dart:async'; |
| class Person { |
| String firstName, lastName; |
| @@ -21,17 +26,23 @@ main() { |
| }); |
| } |
| +initializeMessages(String localeName) { |
| + initializeInternalMessageLookup(() => new CompositeMessageLookup()); |
| + messageLookup.addLocale(localeName, (_) => null); |
| + return new Future.immediate(null); |
|
Emily Fortuna
2013/03/13 18:54:43
do you need to return a future here if it's always
Alan Knight
2013/03/14 17:49:05
Hmm. Actually, I think the thing to do is delete t
|
| +} |
| + |
| runTests(_) { |
| test('Trivial Message', () { |
| hello() => Intl.message('Hello, world!', |
| desc: 'hello world string'); |
| - expect(hello(), completion(equals('Hello, world!'))); |
| + expect(hello(), 'Hello, world!'); |
| }); |
| test('Message with one parameter', () { |
| lucky(number) => Intl.message('Your lucky number is $number', |
| desc: 'number str', examples: {'number': 2}); |
| - expect(lucky(3), completion(equals('Your lucky number is 3'))); |
| + expect(lucky(3), 'Your lucky number is 3'); |
| }); |
| test('Message with multiple plural cases (whole message)', () { |
| @@ -42,9 +53,9 @@ runTests(_) { |
| 'other': 'There are $number emails left.'}), |
| desc: 'Message telling user how many emails will be sent.', |
| examples: {'number': 32}); |
| - expect(emails(5), completion(equals('There are 5 emails left.'))); |
| - expect(emails(0), completion(equals('There are no emails left.'))); |
| - expect(emails(1), completion(equals('There is one email left.'))); |
| + expect(emails(5), 'There are 5 emails left.'); |
| + expect(emails(0), 'There are no emails left.'); |
| + expect(emails(1), 'There is one email left.'); |
| }); |
| test('Message with multiple plural cases (partial message)', () { |
| @@ -55,9 +66,9 @@ runTests(_) { |
| 'other': 'are'})} $number messages left.", |
| desc: 'Message telling user how many emails will be sent.', |
| examples: {'number': 32}); |
| - expect(emails(5), completion(equals('There are 5 messages left.'))); |
| - expect(emails(0), completion(equals('There are 0 messages left.'))); |
| - expect(emails(1), completion(equals('There is 1 messages left.'))); |
| + expect(emails(5), 'There are 5 messages left.'); |
| + expect(emails(0), 'There are 0 messages left.'); |
| + expect(emails(1), 'There is 1 messages left.'); |
| }); |
| test('Message with dictionary parameter', () { |
| @@ -66,7 +77,7 @@ runTests(_) { |
| desc: "States a person's name.", |
| examples: {'first': 'Ford', 'last': 'Prefect'}); |
| expect(hello({'first' : 'Ford', 'last' : 'Prefect'}), |
| - completion(equals('Hello, my name is Ford Prefect'))); |
| + 'Hello, my name is Ford Prefect'); |
| }); |
| test('Message with object parameter', () { |
| @@ -75,19 +86,18 @@ runTests(_) { |
| desc: "States a person's name.", |
| examples: {'first': 'Ford', 'last' : 'Prefect'}); |
| var ford = new Person('Ford', 'Prefect'); |
| - expect(hello(ford), completion(equals('Hello, my name is Ford Prefect.'))); |
| + expect(hello(ford), 'Hello, my name is Ford Prefect.'); |
| }); |
| test('WithLocale test', () { |
| hello() => Intl.message('locale=${Intl.getCurrentLocale()}', |
| desc: 'explains the locale'); |
| - expect(Intl.withLocale('en-US', () => hello()), |
| - completion(equals('locale=en-US'))); |
| + expect(Intl.withLocale('en-US', () => hello()), 'locale=en-US'); |
| }); |
| test('Test passing locale', () { |
| hello(a_locale) => Intl.message('locale=${Intl.getCurrentLocale()}', |
| desc: 'explains the locale', locale: a_locale); |
| - expect(hello('en-US'), completion(equals('locale=en_US'))); |
| + expect(hello('en-US'), 'locale=en_US'); |
| }); |
| } |