Skip to content

Commit

Permalink
Added compiler tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Jun 2, 2021
1 parent b1451e5 commit 316fe71
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compiler/tests/len_array.mpcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// -*- go -*-

package main

type Field [10]int32

// @Test 0 0 = 10
func main(a, b int32) int {
var arr Field
return len(arr)
}
22 changes: 22 additions & 0 deletions compiler/tests/len_array_sum.mpcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -*- go -*-

package main

type Field [10]int32

// @Test 0 0 = 45
// @Test 1 10 = 56
func main(a, b int32) int {
var arr Field

for i := 0; i < len(arr); i++ {
arr[i] = i
}

var sum int32
for i := 0; i < len(arr); i++ {
sum += arr[i]
}

return sum + a + b
}
9 changes: 9 additions & 0 deletions compiler/tests/len_string.mpcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// -*- go -*-

package main

// @Test 0 0 = 13
func main(a, b int32) int {
val := "Hello, world!"
return len(val)
}
15 changes: 15 additions & 0 deletions compiler/tests/len_string_sum.mpcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- go -*-

package main

// @Test 0 0 = 1161
func main(a, b int32) int {
val := "Hello, world!"

var sum int32
for i := 0; i < len(val); i++ {
sum += int32(val[i])
}

return sum
}

0 comments on commit 316fe71

Please sign in to comment.