1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-03 10:29:58 +00:00

More tests

This commit is contained in:
Karol Stasiak 2020-01-17 23:29:39 +01:00
parent 63866fffe3
commit 921a59bdad
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package millfork.test
/**
* @author Karol Stasiak
*/
class ArrayFieldsSuite {
}

View File

@ -790,4 +790,30 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers {
m.readByte(0xc000) should equal(3)
}
}
test("Repeated struct array indexing optimization") {
EmuBenchmarkRun(
"""
| struct A {
| byte padding
| byte x
| byte y
| }
|
| array(A) arr[40]
|
| byte output @$c000
| void main() {
| arr[0].x = 1
| f(0, 50)
| output = arr[0].y
| }
|
| noinline void f(byte i, byte v) {
| arr[i].y = arr[i].x + v
| }
|""".stripMargin){ m =>
m.readByte(0xc000) should equal(51)
}
}
}