aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/languages/LanguageMlTest.php
blob: d8d3e0d7c0fe5281883620961406fa71d42d90f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
 * @author Santhosh Thottingal
 * @copyright Copyright © 2011, Santhosh Thottingal
 * @file
 */

/**
 * @group Language
 * @covers \LanguageMl
 */
class LanguageMlTest extends LanguageClassesTestCase {

	/**
	 * @dataProvider provideFormatNum
	 * @covers \MediaWiki\Language\Language::formatNum
	 */
	public function testFormatNum( $value, $result ) {
		// For T31495
		$this->assertEquals( $result, $this->getLang()->formatNum( $value ) );
	}

	public static function provideFormatNum() {
		return [
			[ '1234567', '12,34,567' ],
			[ '12345', '12,345' ],
			[ '1', '1' ],
			[ '123', '123' ],
			[ '1234', '1,234' ],
			[ '12345.56', '12,345.56' ],
			[ '12345679812345678', '12,34,56,79,81,23,45,678' ],
			[ '.12345', '.12345' ],
			[ '-1200000', '−12,00,000' ],
			[ '-98', '−98' ],
			[ -98, '−98' ],
			[ -12345678, '−1,23,45,678' ],
			[ '', '' ],
			[ null, '' ],
		];
	}

	/**
	 * @covers \LanguageMl::normalize
	 * @covers \MediaWiki\Language\Language::normalize
	 * @dataProvider provideNormalize
	 */
	public function testNormalize( $input, $expected ) {
		if ( $input === $expected ) {
			$this->fail( 'Expected output must differ.' );
		}

		$this->assertSame(
			$expected,
			$this->getLang()->normalize( $input ),
			'ml-normalised form'
		);
	}

	public static function provideNormalize() {
		return [
			[
				'ല്‍',
				'ൽ',
			],
			[
				'ര്‍',
				'ർ',
			],
			[
				'ള്‍',
				'ൾ',
			],
		];
	}
}