28 lines
614 B
Plaintext
28 lines
614 B
Plaintext
// Test backward type propagation
|
|
// Functions that use typed ops on parameters should have
|
|
// parameter types inferred and type checks eliminated
|
|
|
|
var sum_ints = function(a, b, c) {
|
|
return a + b + c
|
|
}
|
|
|
|
var count_down = function(n) {
|
|
var i = n
|
|
var total = 0
|
|
while (i > 0) {
|
|
total = total + i
|
|
i = i - 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
var concat_all = function(a, b, c) {
|
|
return a + b + c
|
|
}
|
|
|
|
if (sum_ints(1, 2, 3) != 6) { print("FAIL sum_ints") }
|
|
if (count_down(5) != 15) { print("FAIL count_down") }
|
|
if (concat_all("a", "b", "c") != "abc") { print("FAIL concat_all") }
|
|
|
|
print("backward type tests passed")
|