Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test for java.lang.String#hashCode()
  • Loading branch information
chitoku-k committed May 7, 2019
commit d151fe70015987c09f4cd8177616d1a1a3c782da
18 changes: 18 additions & 0 deletions tests/Packages/JavaLangStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ public function testConcat()
$this->assertEquals('abcdef', $value);
}

public function testHashCode()
{
ob_start();
$this->initiatedJavaClasses['JavaUtilStringTest']
->getInvoker()
->getStatic()
->getMethods()
->call(
'testHashCode'
);

$values = array_filter(explode("\n", ob_get_clean()));
$this->assertCount(3, $values);
$this->assertSame('2728214739616339340', $values[0]);
$this->assertSame('2728214739616339340', $values[1]);
$this->assertSame('2728214739616339340', $values[2]);
}

public function testReplace()
{
ob_start();
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/java/JavaLangStringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public static void concat(String a, String b)
System.out.print(a.concat(b));
}

public static void testHashCode()
{
System.out.println(Objects.hashCode("hello, world"));
System.out.println(Objects.hashCode("HELLO, WORLD".toLowerCase()));
System.out.println(Objects.hashCode(new String("hello, world")));
}

public static void replace(String a, String b, String c)
{
System.out.print(a.replace(b, c));
Expand Down