Skip to content

Commit 60c2762

Browse files
committed
Add array tests
1 parent a676a0e commit 60c2762

10 files changed

Lines changed: 94 additions & 12 deletions

File tree

src/Kernel/Mnemonics/_baload.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Utilities\Extractor;
65

76
final class _baload implements OperationInterface

src/Kernel/Mnemonics/_bastore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\Type;
65
use PHPJava\Utilities\Extractor;
76

src/Kernel/Mnemonics/_caload.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Utilities\Extractor;
65

76
final class _caload implements OperationInterface

src/Kernel/Mnemonics/_dstore.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Kernel\Types\_Double;
5-
use PHPJava\Utilities\BinaryTool;
64
use PHPJava\Utilities\Extractor;
75

86
final class _dstore implements OperationInterface

src/Kernel/Mnemonics/_faload.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
5-
use PHPJava\Kernel\Types\Type;
64
use PHPJava\Utilities\Extractor;
75

86
final class _faload implements OperationInterface

src/Kernel/Mnemonics/_fastore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\Type;
65
use PHPJava\Utilities\Extractor;
76

src/Kernel/Mnemonics/_saload.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Utilities\Extractor;
65

76
final class _saload implements OperationInterface

src/Kernel/Mnemonics/_sastore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\Type;
65
use PHPJava\Utilities\Extractor;
76

tests/ArrayTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,64 @@ public function testCreateStringArray()
3535
$this->assertEquals('bar', $actual->offsetGet(1));
3636
$this->assertEquals('baz', $actual->offsetGet(2));
3737
}
38+
39+
public function testCreateLongArray()
40+
{
41+
$actual = $this->call('createLongArray');
42+
43+
$this->assertEquals(3, $actual->count());
44+
$this->assertEquals('1', $actual->offsetGet(0));
45+
$this->assertEquals('2', $actual->offsetGet(1));
46+
$this->assertEquals('3', $actual->offsetGet(2));
47+
}
48+
49+
public function testCreateFloatArray()
50+
{
51+
$actual = $this->call('createFloatArray');
52+
53+
$this->assertEquals(3, $actual->count());
54+
$this->assertEquals('1.5', $actual->offsetGet(0));
55+
$this->assertEquals('2.5', $actual->offsetGet(1));
56+
$this->assertEquals('3.5', $actual->offsetGet(2));
57+
}
58+
59+
public function testCreateDoubleArray()
60+
{
61+
$actual = $this->call('createDoubleArray');
62+
63+
$this->assertEquals(3, $actual->count());
64+
$this->assertEquals('1.5', $actual->offsetGet(0));
65+
$this->assertEquals('2.5', $actual->offsetGet(1));
66+
$this->assertEquals('3.5', $actual->offsetGet(2));
67+
}
68+
69+
public function testCreateBooleanArray()
70+
{
71+
$actual = $this->call('createBooleanArray');
72+
73+
$this->assertEquals(3, $actual->count());
74+
$this->assertEquals('1', $actual->offsetGet(0));
75+
$this->assertEquals('0', $actual->offsetGet(1));
76+
$this->assertEquals('1', $actual->offsetGet(2));
77+
}
78+
79+
public function testCreateCharArray()
80+
{
81+
$actual = $this->call('createCharArray');
82+
83+
$this->assertEquals(3, $actual->count());
84+
$this->assertEquals('A', $actual->offsetGet(0));
85+
$this->assertEquals('B', $actual->offsetGet(1));
86+
$this->assertEquals('C', $actual->offsetGet(2));
87+
}
88+
89+
public function testCreateByteArray()
90+
{
91+
$actual = $this->call('createByteArray');
92+
93+
$this->assertEquals(3, $actual->count());
94+
$this->assertEquals('1', $actual->offsetGet(0));
95+
$this->assertEquals('2', $actual->offsetGet(1));
96+
$this->assertEquals('3', $actual->offsetGet(2));
97+
}
3898
}

tests/fixtures/java/ArrayTest.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,43 @@ class ArrayTest
22
{
33
public static int[] createIntArray()
44
{
5-
return new int[] { 1, 2, 3 };
5+
return new int[] { 1, 2, 3 };
66
}
77

88
public static String[] createStringArray()
99
{
10-
return new String[] { "foo", "bar", "baz" };
10+
return new String[] { "foo", "bar", "baz" };
11+
}
12+
13+
public static long[] createLongArray()
14+
{
15+
return new long[] { 1, 2, 3 };
16+
}
17+
18+
public static float[] createFloatArray()
19+
{
20+
return new float[] { 1.5F, 2.5F, 3.5F };
21+
}
22+
23+
public static double[] createDoubleArray()
24+
{
25+
return new double[] { 1.5, 2.5, 3.5 };
26+
}
27+
28+
public static boolean[] createBooleanArray()
29+
{
30+
return new boolean[] { true, false, true };
31+
}
32+
33+
public static char[] createCharArray()
34+
{
35+
return new char[] { 'A', 'B', 'C' };
36+
}
37+
38+
39+
public static byte[] createByteArray()
40+
{
41+
return new byte[] { 0x01, 0x02, 0x03 };
42+
1143
}
1244
}

0 commit comments

Comments
 (0)