Skip to content

Commit

Permalink
Merge branch 'release/0.31.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Nov 5, 2018
2 parents 5a93673 + fb1eac5 commit e5c83f9
Show file tree
Hide file tree
Showing 46 changed files with 704 additions and 576 deletions.
59 changes: 36 additions & 23 deletions build/supertiny.flx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import "libc" as _
{
printf("yay\n")
}


overloadErrorTest()
}


Expand Down Expand Up @@ -73,32 +76,42 @@ import "libc" as _



// fn overloadErrorTest()
// {
// fn printThings(mul: f64, flts: [f64: ...])
// {
// printf("floats: ");
// for i in flts { printf("%.1f ", mul * i) }
fn overloadErrorTest()
{
fn printThings(mul: f64, flts: [f64: ...])
{
printf("floats: ");
for i in flts { printf("%.1f ", mul * i) }

printf("\n")
}

fn printThings(mul: str, flts: [f64: ...])
{
printf("floats: ");
for i in flts { printf("%s: %.1f ", mul.ptr, i) }

printf("\n")
}

fn printThings()
{
printf("print things 3\n")
}

do {
printThings(30, ...[as f64: 1, 2, 3, 4, 5 ])
printThings(0.813, 1, 2, 4.41, 39, 491.3, 381.7)
}
}






// printf("\n")
// }

// fn printThings(mul: str, flts: [f64: ...])
// {
// printf("floats: ");
// for i in flts { printf("%s: %.1f ", mul.ptr, i) }

// printf("\n")
// }

// fn printThings()
// {
// printf("print things 3\n")
// }


// do {
// printThings(30, ...[ 1, 2, 3, 4, 5 ])
// printThings(0.813, 1, 2, 4.41, 39, 491.3, 381.7)
// }
// }
110 changes: 55 additions & 55 deletions build/tester.flx
Original file line number Diff line number Diff line change
Expand Up @@ -49,127 +49,127 @@ fn runTests()
let endTitle = "============ TESTS COMPLETE ============\n"


libc.printf("%s%s", fibTitle, thinLine)
libc::printf("%s%s", fibTitle, thinLine)
do {
var n = 1
while n < 20
{
libc.printf("%d", test_fib.doRecursiveFib(n))
libc::printf("%d", test_fib::doRecursiveFib(n))
n += 1

if n != 20
{
libc.printf(", ")
libc::printf(", ")
}
}
libc.printf("\n\n\n")
libc::printf("\n\n\n")
}

// fizzbuzz
libc.printf("%s%s", fizzbuzzTitle, thinLine)
test_fizz.doFizzBuzz(15)
libc.printf("\n\n\n")
libc::printf("%s%s", fizzbuzzTitle, thinLine)
test_fizz::doFizzBuzz(15)
libc::printf("\n\n\n")


// int limits
libc.printf("%s%s", intLimitsTitle, thinLine)
test_limits.printIntegerLimits()
libc.printf("\n\n\n")
libc::printf("%s%s", intLimitsTitle, thinLine)
test_limits::printIntegerLimits()
libc::printf("\n\n\n")


// scopes
libc.printf("%s%s", scopeTitle, thinLine)
test_scopes.doScopeTest("__llvm_jit__build/test")
libc.printf("\n\n\n")
libc::printf("%s%s", scopeTitle, thinLine)
test_scopes::doScopeTest("__llvm_jit__build/test")
libc::printf("\n\n\n")


// operators and tuples (vectors type, mainly)
libc.printf("%s%s", operatorTitle, thinLine)
libc::printf("%s%s", operatorTitle, thinLine)
// doOperatorTupleTest()
libc.printf("\n\n\n")
libc::printf("\n\n\n")


// arrays
libc.printf("%s%s", arrayTitle, thinLine)
test_arrays.doArrayTest()
libc.printf("\n\n\n")
libc::printf("%s%s", arrayTitle, thinLine)
test_arrays::doArrayTest()
libc::printf("\n\n\n")


// generics
libc.printf("%s%s", genericsTitle, thinLine)
test_generics.doGenericsTest()
libc.printf("\n\n\n")
libc::printf("%s%s", genericsTitle, thinLine)
test_generics::doGenericsTest()
libc::printf("\n\n\n")


// classes
libc.printf("%s%s", classTitle, thinLine)
test_classes.doClassTest()
libc.printf("\n\n\n")
libc::printf("%s%s", classTitle, thinLine)
test_classes::doClassTest()
libc::printf("\n\n\n")


// first-class-functions
libc.printf("%s%s", functionsTitle, thinLine)
test_functions.doFunctionTest()
libc.printf("\n\n\n")
libc::printf("%s%s", functionsTitle, thinLine)
test_functions::doFunctionTest()
libc::printf("\n\n\n")


// defer semantics
libc.printf("%s%s", deferTitle, thinLine)
test_defer.doDeferTest()
libc.printf("\n\n\n")
libc::printf("%s%s", deferTitle, thinLine)
test_defer::doDeferTest()
libc::printf("\n\n\n")


// any
libc.printf("%s%s", anyTitle, thinLine)
test_any.doAnyTest()
libc.printf("\n\n\n")
libc::printf("%s%s", anyTitle, thinLine)
test_any::doAnyTest()
libc::printf("\n\n\n")


// slices
libc.printf("%s%s", slicesTitle, thinLine)
test_slices.doSlicesTest()
libc.printf("\n\n\n")
libc::printf("%s%s", slicesTitle, thinLine)
test_slices::doSlicesTest()
libc::printf("\n\n\n")


// decomposition
libc.printf("%s%s", decomposeTitle, thinLine)
test_decomposition.doDecompositionTest()
libc.printf("\n\n\n")
libc::printf("%s%s", decomposeTitle, thinLine)
test_decomposition::doDecompositionTest()
libc::printf("\n\n\n")


// for-loops
libc.printf("%s%s", forLoopTitle, thinLine)
test_forloops.doForLoopTest()
libc.printf("\n\n\n")
libc::printf("%s%s", forLoopTitle, thinLine)
test_forloops::doForLoopTest()
libc::printf("\n\n\n")


// linked-list (generics)
libc.printf("%s%s", linkedListTitle, thinLine)
test_linkedlist.doLinkedListTest()
libc.printf("\n\n\n")
libc::printf("%s%s", linkedListTitle, thinLine)
test_linkedlist::doLinkedListTest()
libc::printf("\n\n\n")


// unions (generics)
libc.printf("%s%s", unionsTitle, thinLine)
test_unions.doUnionsTest()
libc.printf("\n\n\n")
libc::printf("%s%s", unionsTitle, thinLine)
test_unions::doUnionsTest()
libc::printf("\n\n\n")


// using
libc.printf("%s%s", usingTitle, thinLine)
test_using.doUsingTest()
libc.printf("\n\n\n")
libc::printf("%s%s", usingTitle, thinLine)
test_using::doUsingTest()
libc::printf("\n\n\n")


// misc tests
libc.printf("%s%s", miscTitle, thinLine)
libc::printf("%s%s", miscTitle, thinLine)
// miscellaneousTests()
libc.printf("\n\n\n")
libc::printf("\n\n\n")



// fin.
libc.printf("%s\n\n\n\n\n", endTitle)
libc::printf("%s\n\n\n\n\n", endTitle)
}


Expand All @@ -185,7 +185,7 @@ fn runTests()
runTests()


libc.printf("\n<< done >>\n")
libc::printf("\n<< done >>\n")
return 0
}

Expand Down
30 changes: 15 additions & 15 deletions build/tests/arraytest.flx
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ public fn doArrayTest()
var arr: [[int: 2]: 2] = [ [ 1, 2 ], [ 5, 6 ] ]
arr[1][1] = 400

libc.printf("a[0][0]: %d, a[0][1]: %d, a[1][0]: %d, a[1][1]: %d\n", arr[0][0], arr[0][1], arr[1][0], arr[1][1])
libc::printf("a[0][0]: %d, a[0][1]: %d, a[1][0]: %d, a[1][1]: %d\n", arr[0][0], arr[0][1], arr[1][0], arr[1][1])

var d: [f64: 4] = [ 1.0, 2.0, 4.0, 8.0 ]
libc.printf("d[0]: %f, d[1]: %f, d[2]: %f, d[3]: %f\n", d[0], d[1], d[2], d[3]);
libc::printf("d[0]: %f, d[1]: %f, d[2]: %f, d[3]: %f\n", d[0], d[1], d[2], d[3]);


var arr1: &mut int = @raw alloc mut int [4]
arr1[1] = 97
arr1[2] = 43

libc.printf("arr[1] = %d\n", (arr1 + 1)[0])
libc.printf("arr[2] = %d\n", (3 + arr1)[-1])
libc::printf("arr[1] = %d\n", (arr1 + 1)[0])
libc::printf("arr[2] = %d\n", (3 + arr1)[-1])

free arr1

libc.printf("\n\n")
libc::printf("\n\n")
// var s = alloc[4][4] string("array of array of strings test")
// s[1][2] = "BOO YOU STRING"

// libc.printf("s[1][2] = %s, s[1][2].length = %ld\n", s[1][2], s[1][2].length)
// libc::printf("s[1][2] = %s, s[1][2].length = %ld\n", s[1][2], s[1][2].length)

// free s
}

libc.printf("\n")
libc::printf("\n")
dynamicArrays()
}

Expand Down Expand Up @@ -73,9 +73,9 @@ fn setup(max: int) -> [int]
fn dynamicArrays()
{
do {
libc.printf("PRE X\n")
libc::printf("PRE X\n")
var x: [string]
libc.printf("POST X\n")
libc::printf("POST X\n")
var y = alloc string [5]

var i = 0
Expand All @@ -91,26 +91,26 @@ fn dynamicArrays()
let k = x
var z = k.clone()

libc.printf("z.length = %d\n", z.length)
libc::printf("z.length = %d\n", z.length)

z[9] = string("LAST ELEMENT")

libc.printf("z <= x: %d\n", z <= x)
libc::printf("z <= x: %d\n", z <= x)

while i < z.length
{
libc.printf("z[%ld] = %s // %ld\n", i, z[i], z[i].refcount)
libc::printf("z[%ld] = %s // %ld\n", i, z[i], z[i].refcount)
i += 1
}

libc.printf("z.back() = %s, length = %ld, cap = %ld\n", z[z.length - 1], z.length, z.capacity)
libc::printf("z.back() = %s, length = %ld, cap = %ld\n", z[z.length - 1], z.length, z.capacity)

libc.printf("x == k ? %d\n", x == k)
libc::printf("x == k ? %d\n", x == k)

let fib = setup(5)

let sum = foldl(fib, 1, f)
libc.printf("sum = %d\n", sum)
libc::printf("sum = %d\n", sum)
}
}

Expand Down
10 changes: 5 additions & 5 deletions build/tests/fizzbuzz.flx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ public fn doFizzBuzz(num: int)
var i = 0
while i <= num
{
libc.printf("%02d: ", i)
libc::printf("%02d: ", i)

if i % 3 == 0
{
libc.printf("Fizz")
libc::printf("Fizz")
}
if i % 5 == 0
{
libc.printf("Buzz")
libc::printf("Buzz")
}

if i % 5 != 0 && i % 3 != 0
{
libc.printf("%d", i)
libc::printf("%d", i)
}

libc.printf("\n")
libc::printf("\n")
i += 1
}
}
Loading

0 comments on commit e5c83f9

Please sign in to comment.