| OLD | NEW |
| 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 | |
| 6 #library('intl_message_test'); | 5 #library('intl_message_test'); |
| 7 | 6 |
| 8 #import('../intl.dart'); | 7 #import('../intl.dart'); |
| 9 #import('../../../pkg/unittest/unittest.dart'); | 8 #import('../../unittest/unittest.dart'); |
| 9 #import('../message_lookup_local.dart'); |
| 10 | 10 |
| 11 /** Tests the MessageFormat library in dart. */ | 11 /** Tests the MessageFormat library in dart. */ |
| 12 | 12 |
| 13 class Person { | 13 class Person { |
| 14 String firstName, lastName; | 14 String firstName, lastName; |
| 15 Person(this.firstName, this.lastName); | 15 Person(this.firstName, this.lastName); |
| 16 } | 16 } |
| 17 | 17 |
| 18 main() { | 18 main() { |
| 19 initializeMessages('en_US').then(runTests); |
| 20 } |
| 21 |
| 22 runTests(_) { |
| 19 test('Trivial Message', () { | 23 test('Trivial Message', () { |
| 20 hello() => Intl.message('Hello, world!', | 24 hello() => Intl.message('Hello, world!', |
| 21 desc: 'hello world string'); | 25 desc: 'hello world string'); |
| 22 expect(hello(), equals('Hello, world!')); | 26 expect(hello(), equals('Hello, world!')); |
| 23 }); | 27 }); |
| 24 | 28 |
| 25 test('Message with one parameter', () { | 29 test('Message with one parameter', () { |
| 26 lucky(number) => Intl.message('Your lucky number is $number', | 30 lucky(number) => Intl.message('Your lucky number is $number', |
| 27 desc: 'number str', examples: {'number': 2}); | 31 desc: 'number str', examples: {'number': 2}); |
| 28 expect(lucky(3), equals('Your lucky number is 3')); | 32 expect(lucky(3), equals('Your lucky number is 3')); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 desc: 'explains the locale'); | 81 desc: 'explains the locale'); |
| 78 expect(Intl.withLocale('en-US', () => hello()), equals('locale=en-US')); | 82 expect(Intl.withLocale('en-US', () => hello()), equals('locale=en-US')); |
| 79 }); | 83 }); |
| 80 | 84 |
| 81 test('Test passing locale', () { | 85 test('Test passing locale', () { |
| 82 hello(a_locale) => Intl.message('locale=${Intl.getCurrentLocale()}', | 86 hello(a_locale) => Intl.message('locale=${Intl.getCurrentLocale()}', |
| 83 desc: 'explains the locale', locale: a_locale); | 87 desc: 'explains the locale', locale: a_locale); |
| 84 expect(hello('en-US'), equals('locale=en_US')); | 88 expect(hello('en-US'), equals('locale=en_US')); |
| 85 }); | 89 }); |
| 86 } | 90 } |
| OLD | NEW |