| 1 |
( function () { |
| 2 |
const pluralTestcases = { |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
en: [ |
| 10 |
[ 0, [ 'one', 'other' ], 'other', 'English plural test- 0 is other' ], |
| 11 |
[ 1, [ 'one', 'other' ], 'one', 'English plural test- 1 is one' ] |
| 12 |
], |
| 13 |
fa: [ |
| 14 |
[ 0, [ 'one', 'other' ], 'other', 'Persian plural test- 0 is other' ], |
| 15 |
[ 1, [ 'one', 'other' ], 'one', 'Persian plural test- 1 is one' ], |
| 16 |
[ 2, [ 'one', 'other' ], 'other', 'Persian plural test- 2 is other' ] |
| 17 |
], |
| 18 |
fr: [ |
| 19 |
[ 0, [ 'one', 'other' ], 'other', 'French plural test- 0 is other' ], |
| 20 |
[ 1, [ 'one', 'other' ], 'one', 'French plural test- 1 is one' ] |
| 21 |
], |
| 22 |
hi: [ |
| 23 |
[ 0, [ 'one', 'other' ], 'one', 'Hindi plural test- 0 is one' ], |
| 24 |
[ 1, [ 'one', 'other' ], 'one', 'Hindi plural test- 1 is one' ], |
| 25 |
[ 2, [ 'one', 'other' ], 'other', 'Hindi plural test- 2 is other' ] |
| 26 |
], |
| 27 |
he: [ |
| 28 |
[ 0, [ 'one', 'other' ], 'other', 'Hebrew plural test- 0 is other' ], |
| 29 |
[ 1, [ 'one', 'other' ], 'one', 'Hebrew plural test- 1 is one' ], |
| 30 |
[ 2, [ 'one', 'other' ], 'other', 'Hebrew plural test- 2 is other with 2 forms' ], |
| 31 |
[ 2, [ 'one', 'dual', 'other' ], 'dual', 'Hebrew plural test- 2 is dual with 3 forms' ] |
| 32 |
], |
| 33 |
hu: [ |
| 34 |
[ 0, [ 'one', 'other' ], 'other', 'Hungarian plural test- 0 is other' ], |
| 35 |
[ 1, [ 'one', 'other' ], 'one', 'Hungarian plural test- 1 is one' ], |
| 36 |
[ 2, [ 'one', 'other' ], 'other', 'Hungarian plural test- 2 is other' ] |
| 37 |
], |
| 38 |
hy: [ |
| 39 |
[ 0, [ 'one', 'other' ], 'other', 'Armenian plural test- 0 is other' ], |
| 40 |
[ 1, [ 'one', 'other' ], 'one', 'Armenian plural test- 1 is one' ], |
| 41 |
[ 2, [ 'one', 'other' ], 'other', 'Armenian plural test- 2 is other' ] |
| 42 |
], |
| 43 |
ar: [ |
| 44 |
[ 0, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'zero', 'Arabic plural test - 0 is zero' ], |
| 45 |
[ 1, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'one', 'Arabic plural test - 1 is one' ], |
| 46 |
[ 2, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'two', 'Arabic plural test - 2 is two' ], |
| 47 |
[ 3, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'few', 'Arabic plural test - 3 is few' ], |
| 48 |
[ 9, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'few', 'Arabic plural test - 9 is few' ], |
| 49 |
[ '9', [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'few', 'Arabic plural test - 9 is few' ], |
| 50 |
[ 110, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'few', 'Arabic plural test - 110 is few' ], |
| 51 |
[ 11, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'many', 'Arabic plural test - 11 is many' ], |
| 52 |
[ 15, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'many', 'Arabic plural test - 15 is many' ], |
| 53 |
[ 99, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'many', 'Arabic plural test - 99 is many' ], |
| 54 |
[ 9999, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'many', 'Arabic plural test - 9999 is many' ], |
| 55 |
[ 100, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'other', 'Arabic plural test - 100 is other' ], |
| 56 |
[ 102, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'other', 'Arabic plural test - 102 is other' ], |
| 57 |
[ 1000, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'other', 'Arabic plural test - 1000 is other' ], |
| 58 |
[ 1.7, [ 'zero', 'one', 'two', 'few', 'many', 'other' ], 'other', 'Arabic plural test - 1.7 is other' ] |
| 59 |
] |
| 60 |
}; |
| 61 |
|
| 62 |
QUnit.module( 'mediawiki.cldr', QUnit.newMwEnvironment() ); |
| 63 |
|
| 64 |
function pluralTest( langCode, tests ) { |
| 65 |
QUnit.test( 'Plural Test for ' + langCode, ( assert ) => { |
| 66 |
let i; |
| 67 |
for ( i = 0; i < tests.length; i++ ) { |
| 68 |
assert.strictEqual( |
| 69 |
mw.language.convertPlural( tests[ i ][ 0 ], tests[ i ][ 1 ] ), |
| 70 |
tests[ i ][ 2 ], |
| 71 |
tests[ i ][ 3 ] |
| 72 |
); |
| 73 |
} |
| 74 |
} ); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
$.each( pluralTestcases, ( langCode, tests ) => { |
| 79 |
if ( langCode === mw.config.get( 'wgUserLanguage' ) ) { |
| 80 |
pluralTest( langCode, tests ); |
| 81 |
} |
| 82 |
} ); |
| 83 |
}() ); |