Fixed the close over methods and member vars bug, but there's something remaining causing the safe_recursive_delete not to work. Gotta save progress and do other stuff
This commit is contained in:
2
tests/test_close_over_members.expected_results
Normal file
2
tests/test_close_over_members.expected_results
Normal file
@@ -0,0 +1,2 @@
|
||||
4
|
||||
7
|
||||
27
tests/test_close_over_members.krak
Normal file
27
tests/test_close_over_members.krak
Normal file
@@ -0,0 +1,27 @@
|
||||
import io:*
|
||||
|
||||
fun runFunc(func: fun():void) {
|
||||
func()
|
||||
}
|
||||
|
||||
obj ToClose {
|
||||
var data: int
|
||||
fun print4() {
|
||||
println(4)
|
||||
}
|
||||
fun testMethod() {
|
||||
runFunc(fun() { print4(); } )
|
||||
}
|
||||
fun testVariable() {
|
||||
data = 7
|
||||
runFunc(fun() { println(data); } )
|
||||
}
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
var it: ToClose
|
||||
it.testMethod()
|
||||
it.testVariable()
|
||||
return 0
|
||||
}
|
||||
|
||||
1
tests/test_comparison_overload.expected_results
Normal file
1
tests/test_comparison_overload.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
false
|
||||
25
tests/test_comparison_overload.krak
Normal file
25
tests/test_comparison_overload.krak
Normal file
@@ -0,0 +1,25 @@
|
||||
import io:*
|
||||
|
||||
fun Comparable<T>(): Comparable<T> {
|
||||
var toRet : Comparable<T>
|
||||
return toRet
|
||||
}
|
||||
|
||||
fun Comparable<T>(item: T): Comparable<T> {
|
||||
var toRet : Comparable<T>
|
||||
return toRet
|
||||
}
|
||||
|
||||
obj Comparable<T> {
|
||||
fun operator==(other: Comparable<T>):bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
var first: Comparable<int>
|
||||
var second: Comparable<int>
|
||||
println(first == second)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
Lookie, a map!
|
||||
What I get for not testing different types
|
||||
key: 7, value: Lookie, a map!
|
||||
key: 20, value: What I get for not testing different types
|
||||
key: 30, value: we'll look for for_each too
|
||||
|
||||
@@ -21,6 +21,7 @@ fun main():int {
|
||||
mapEx[30] = "we'll look for for_each too"
|
||||
println(mapEx[7])
|
||||
println(mapEx[20])
|
||||
mapEx.remove(20)
|
||||
mapEx.for_each(fun(key:int, value:char*) { print("key: "); print(key); print(", value: "); println(value); })
|
||||
return 0
|
||||
}
|
||||
|
||||
13
tests/test_set.expected_results
Normal file
13
tests/test_set.expected_results
Normal file
@@ -0,0 +1,13 @@
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
4
|
||||
5
|
||||
24
tests/test_set.krak
Normal file
24
tests/test_set.krak
Normal file
@@ -0,0 +1,24 @@
|
||||
import io:*
|
||||
import set:*
|
||||
|
||||
fun main():int {
|
||||
var s = set(3)
|
||||
println(s.contains(3))
|
||||
println(s.contains(1))
|
||||
s.remove(3)
|
||||
s.add(4)
|
||||
println(s.contains(3))
|
||||
println(s.contains(4))
|
||||
|
||||
println(s == set(4))
|
||||
println(s == set(5))
|
||||
s.add(set(5))
|
||||
println(s == set(4))
|
||||
println(s == set(5))
|
||||
println(s.contains(3))
|
||||
println(s.contains(4))
|
||||
println(s.contains(5))
|
||||
|
||||
s.for_each( fun(it: int) println(it); )
|
||||
return 0
|
||||
}
|
||||
@@ -25,10 +25,83 @@ find test
|
||||
0
|
||||
1
|
||||
2
|
||||
set and []= test
|
||||
set, []=, and delete test
|
||||
4
|
||||
8
|
||||
9
|
||||
7
|
||||
delete
|
||||
4
|
||||
8
|
||||
7
|
||||
delete v2
|
||||
Constructed: 100
|
||||
Constructed: 200
|
||||
Constructed: 300
|
||||
Copied: 100 to 101
|
||||
Copied: 200 to 201
|
||||
Copied: 300 to 301
|
||||
Copied: 101 to 102
|
||||
Copied: 102 to 103
|
||||
Copied: 103 to 104
|
||||
Destroyed: 103
|
||||
Destroyed: 102
|
||||
Copied: 201 to 202
|
||||
Copied: 202 to 203
|
||||
Copied: 203 to 204
|
||||
Destroyed: 203
|
||||
Destroyed: 202
|
||||
Copied: 301 to 302
|
||||
Copied: 302 to 303
|
||||
Copied: 303 to 304
|
||||
Destroyed: 303
|
||||
Destroyed: 302
|
||||
Copied: 104 to 105
|
||||
Copied: 105 to 106
|
||||
Copied: 106 to 107
|
||||
Destroyed: 106
|
||||
Destroyed: 105
|
||||
Copied: 204 to 205
|
||||
Copied: 205 to 206
|
||||
Copied: 206 to 207
|
||||
Destroyed: 206
|
||||
Destroyed: 205
|
||||
Copied: 304 to 305
|
||||
Copied: 305 to 306
|
||||
Copied: 306 to 307
|
||||
Destroyed: 306
|
||||
Destroyed: 305
|
||||
Destroyed: 204
|
||||
Destroyed: 304
|
||||
Destroyed: 104
|
||||
Destroyed: 301
|
||||
Destroyed: 201
|
||||
Destroyed: 101
|
||||
Copied: 107 to 108
|
||||
Copied: 108 to 109
|
||||
Copied: 109 to 110
|
||||
Destroyed: 109
|
||||
Destroyed: 108
|
||||
Copied: 207 to 208
|
||||
Copied: 208 to 209
|
||||
Copied: 209 to 210
|
||||
Destroyed: 209
|
||||
Destroyed: 208
|
||||
Copied: 307 to 308
|
||||
Copied: 308 to 309
|
||||
Copied: 309 to 310
|
||||
Destroyed: 309
|
||||
Destroyed: 308
|
||||
Destroyed: 207
|
||||
Destroyed: 307
|
||||
Destroyed: 107
|
||||
Destroyed: 210
|
||||
Copied: 310 to 311
|
||||
Destroyed: 310
|
||||
done
|
||||
Destroyed: 311
|
||||
Destroyed: 110
|
||||
Destroyed: 300
|
||||
Destroyed: 200
|
||||
Destroyed: 100
|
||||
Destroyed: 0
|
||||
|
||||
@@ -107,16 +107,26 @@ fun main(): int {
|
||||
|
||||
println("find test")
|
||||
var multipleFindTest = vector(1,2,3)
|
||||
println(multipleFindTest.find_index(1))
|
||||
println(multipleFindTest.find_index(2))
|
||||
println(multipleFindTest.find_index(3))
|
||||
println(multipleFindTest.find(1))
|
||||
println(multipleFindTest.find(2))
|
||||
println(multipleFindTest.find(3))
|
||||
|
||||
println("set and []= test")
|
||||
println("set, []=, and delete test")
|
||||
var setTest = vector(4,5,6)
|
||||
setTest.add(7)
|
||||
setTest.set(1,8)
|
||||
setTest[2] = 9
|
||||
setTest.do(fun(it: int) println(it);)
|
||||
println("delete")
|
||||
setTest.remove(2)
|
||||
setTest.do(fun(it: int) println(it);)
|
||||
|
||||
println("delete v2")
|
||||
var firstRem.construct(100): AbleToBeDestroyed;
|
||||
var secondRem.construct(200): AbleToBeDestroyed;
|
||||
var thirdRem.construct(300): AbleToBeDestroyed;
|
||||
var remTest = vector(firstRem, secondRem, thirdRem);
|
||||
remTest.remove(1)
|
||||
|
||||
println("done")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user