◐ Shell
clean mode source ↗

Merge pull request #35 from memory-agape/imitate/classes/methods/java… · php-java/php-java@e46b4ed

Original file line numberDiff line numberDiff line change

@@ -16,4 +16,16 @@ public static function abs($number)

1616

{

1717

return abs($number);

1818

}

19+
20+

/**

21+

* This decrease 1 from parameters

22+

*

23+

* @see https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Math.html#decrementExact-int-

24+

* @param int $a

25+

* @return int

26+

*/

27+

public static function decrementExact($a)

28+

{

29+

return $a - 1;

30+

}

1931

}

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,27 @@

1+

<?php

2+

namespace PHPJava\Tests;

3+
4+

use PHPJava\Core\JavaArchive;

5+

use PHPUnit\Framework\TestCase;

6+
7+

class ImitateJavaLangMathTest extends Base

8+

{

9+

protected $fixtures = [

10+

'ImitateJavaLangMathTest',

11+

];

12+
13+

public function testDecrementExact()

14+

{

15+

ob_start();

16+

$this->initiatedJavaClasses['ImitateJavaLangMathTest']

17+

->getInvoker()

18+

->getStatic()

19+

->getMethods()

20+

->call(

21+

'decrementExact',

22+

1234

23+

);

24+

$value = (int) ob_get_clean();

25+

$this->assertEquals(1233, $value);

26+

}

27+

}

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,7 @@

1+

class ImitateJavaLangMathTest

2+

{

3+

public static void decrementExact(int a)

4+

{

5+

System.out.println(Math.decrementExact(a));

6+

}

7+

}