| 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 | 5 |
| 6 #library('bidi_utils_test'); | 6 #library('bidi_utils_test'); |
| 7 | 7 |
| 8 #import('../../../pkg/i18n/intl.dart'); | 8 #import('../intl.dart'); |
| 9 #import('../../../lib/unittest/unittest.dart'); | 9 #import('../../../lib/unittest/unittest.dart'); |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Tests the bidi utilities library. | 12 * Tests the bidi utilities library. |
| 13 */ | 13 */ |
| 14 main() { | 14 main() { |
| 15 var LRE = '\u202A'; | 15 var LRE = '\u202A'; |
| 16 var RLE = '\u202B'; | 16 var RLE = '\u202B'; |
| 17 var PDF = '\u202C'; | 17 var PDF = '\u202C'; |
| 18 var LRM = '\u200E'; | 18 var LRM = '\u200E'; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 49 | 49 |
| 50 test('hasAnyRtl', () { | 50 test('hasAnyRtl', () { |
| 51 expect(hasAnyRtl(''), isFalse); | 51 expect(hasAnyRtl(''), isFalse); |
| 52 expect(hasAnyRtl('abc'), isFalse); | 52 expect(hasAnyRtl('abc'), isFalse); |
| 53 expect(hasAnyRtl('ab\u05e0c'), isTrue); | 53 expect(hasAnyRtl('ab\u05e0c'), isTrue); |
| 54 expect(hasAnyRtl('123\t... \n'), isFalse); | 54 expect(hasAnyRtl('123\t... \n'), isFalse); |
| 55 expect(hasAnyRtl('<input value=\u05e0>123', false), isTrue); | 55 expect(hasAnyRtl('<input value=\u05e0>123', false), isTrue); |
| 56 expect(hasAnyRtl('<input value=\u05e0>123', true), isFalse); | 56 expect(hasAnyRtl('<input value=\u05e0>123', true), isFalse); |
| 57 }); | 57 }); |
| 58 | 58 |
| 59 | 59 |
| 60 test('endsWithLtr', () { | 60 test('endsWithLtr', () { |
| 61 expect(endsWithLtr('a'), isTrue); | 61 expect(endsWithLtr('a'), isTrue); |
| 62 expect(endsWithLtr('abc'), isTrue); | 62 expect(endsWithLtr('abc'), isTrue); |
| 63 expect(endsWithLtr('a (!)'), isTrue); | 63 expect(endsWithLtr('a (!)'), isTrue); |
| 64 expect(endsWithLtr('a.1'), isTrue); | 64 expect(endsWithLtr('a.1'), isTrue); |
| 65 expect(endsWithLtr('http://www.google.com '), isTrue); | 65 expect(endsWithLtr('http://www.google.com '), isTrue); |
| 66 expect(endsWithLtr('\u05e0a'), isTrue); | 66 expect(endsWithLtr('\u05e0a'), isTrue); |
| 67 expect(endsWithLtr(' \u05e0\u05e1a\u05e2\u05e3 a (!)'), isTrue); | 67 expect(endsWithLtr(' \u05e0\u05e1a\u05e2\u05e3 a (!)'), isTrue); |
| 68 expect(endsWithLtr(''), isFalse); | 68 expect(endsWithLtr(''), isFalse); |
| 69 expect(endsWithLtr(' '), isFalse); | 69 expect(endsWithLtr(' '), isFalse); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 }); | 178 }); |
| 179 | 179 |
| 180 test('normalizeHebrewQuote', () { | 180 test('normalizeHebrewQuote', () { |
| 181 expect(normalizeHebrewQuote('\u05d0"'), equals('\u05d0\u05f4')); | 181 expect(normalizeHebrewQuote('\u05d0"'), equals('\u05d0\u05f4')); |
| 182 expect(normalizeHebrewQuote('\u05d0\''), equals('\u05d0\u05f3')); | 182 expect(normalizeHebrewQuote('\u05d0\''), equals('\u05d0\u05f3')); |
| 183 expect(normalizeHebrewQuote('\u05d0"\u05d0\''), | 183 expect(normalizeHebrewQuote('\u05d0"\u05d0\''), |
| 184 equals('\u05d0\u05f4\u05d0\u05f3')); | 184 equals('\u05d0\u05f4\u05d0\u05f3')); |
| 185 }); | 185 }); |
| 186 | 186 |
| 187 test('estimateDirectionOfText', () { | 187 test('estimateDirectionOfText', () { |
| 188 expect(estimateDirectionOfText('', false).value, | 188 expect(estimateDirectionOfText('', false).value, |
| 189 equals(TextDirection.UNKNOWN.value)); | 189 equals(TextDirection.UNKNOWN.value)); |
| 190 expect(estimateDirectionOfText(' ', false).value, | 190 expect(estimateDirectionOfText(' ', false).value, |
| 191 equals(TextDirection.UNKNOWN.value)); | 191 equals(TextDirection.UNKNOWN.value)); |
| 192 expect(estimateDirectionOfText('! (...)', false).value, | 192 expect(estimateDirectionOfText('! (...)', false).value, |
| 193 equals(TextDirection.UNKNOWN.value)); | 193 equals(TextDirection.UNKNOWN.value)); |
| 194 expect(estimateDirectionOfText('All-Ascii content', false).value, | 194 expect(estimateDirectionOfText('All-Ascii content', false).value, |
| 195 equals(TextDirection.LTR.value)); | 195 equals(TextDirection.LTR.value)); |
| 196 expect(estimateDirectionOfText('-17.0%', false).value, | 196 expect(estimateDirectionOfText('-17.0%', false).value, |
| 197 equals(TextDirection.LTR.value)); | 197 equals(TextDirection.LTR.value)); |
| 198 expect(estimateDirectionOfText('http://foo/bar/', false).value, | 198 expect(estimateDirectionOfText('http://foo/bar/', false).value, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 }); | 337 }); |
| 338 } | 338 } |
| 339 | 339 |
| 340 class SampleItem { | 340 class SampleItem { |
| 341 String text; | 341 String text; |
| 342 bool isRtl; | 342 bool isRtl; |
| 343 bool isHtml; | 343 bool isHtml; |
| 344 SampleItem([someText='', someIsRtl=false, isHtml=false]) : | 344 SampleItem([someText='', someIsRtl=false, isHtml=false]) : |
| 345 this.text=someText, this.isRtl=someIsRtl, this.isHtml=isHtml; | 345 this.text=someText, this.isRtl=someIsRtl, this.isHtml=isHtml; |
| 346 } | 346 } |
| OLD | NEW |