More work on regex, fixed whitespace around && and operator= for vector
This commit is contained in:
@@ -4,3 +4,4 @@ Spam
|
||||
28
|
||||
We'll find out.
|
||||
34
|
||||
woo not
|
||||
|
||||
@@ -15,4 +15,7 @@ fun main(): void {
|
||||
for (var i:int = 0; i < 20; i++;) z++;
|
||||
if (z > 20) io::println("We'll find out.");
|
||||
io::println(z);
|
||||
var boolean = false
|
||||
if ( z > 20 && !boolean)
|
||||
io::println("woo not")
|
||||
}
|
||||
|
||||
@@ -5,5 +5,15 @@ fun main():int {
|
||||
var reg = regex("ab")
|
||||
println(reg.long_match("abab"))
|
||||
println(reg.long_match("aab"))
|
||||
|
||||
println("second")
|
||||
|
||||
reg = regex("a*b+c")
|
||||
println(reg.long_match("bc"))
|
||||
println(reg.long_match("aaaaaaaaaaaaaaaabc"))
|
||||
println(reg.long_match("aaaaaaaaaaaaaaaabbbbbbbbbc"))
|
||||
println(reg.long_match("aaaaaaaaaaaaaaaa"))
|
||||
println(reg.long_match("aaaaaaaaaaaaaaaac"))
|
||||
println(reg.long_match("aaaaaaaaaaaaaaaab"))
|
||||
return 0
|
||||
}
|
||||
|
||||
33
tests/test_util.expected_results
Normal file
33
tests/test_util.expected_results
Normal file
@@ -0,0 +1,33 @@
|
||||
1
|
||||
7.000000
|
||||
2
|
||||
8.000000
|
||||
3
|
||||
hi
|
||||
construct
|
||||
construct with 0
|
||||
construct with 100
|
||||
make_pair
|
||||
copy construct from 0 to 1
|
||||
copy construct from 100 to 101
|
||||
copy construct from 1 to 2
|
||||
copy construct from 101 to 102
|
||||
copy construct from 2 to 3
|
||||
copy construct from 102 to 103
|
||||
destruct with 102
|
||||
destruct with 2
|
||||
copy construct from 3 to 4
|
||||
copy construct from 103 to 104
|
||||
destruct with 3
|
||||
destruct with 103
|
||||
destruct with 101
|
||||
destruct with 1
|
||||
copy construct from 4 to 5
|
||||
copy construct from 104 to 105
|
||||
destruct with 4
|
||||
destruct with 104
|
||||
done
|
||||
destruct with 5
|
||||
destruct with 105
|
||||
destruct with 100
|
||||
destruct with 0
|
||||
45
tests/test_util.krak
Normal file
45
tests/test_util.krak
Normal file
@@ -0,0 +1,45 @@
|
||||
import util:*
|
||||
import io:*
|
||||
|
||||
obj test(Object) {
|
||||
var counter:int
|
||||
fun construct(): test* {
|
||||
counter = 0
|
||||
println("construct with 0")
|
||||
return this
|
||||
}
|
||||
|
||||
fun construct(it:int): test* {
|
||||
counter = it
|
||||
print("construct with "); println(it)
|
||||
return this
|
||||
}
|
||||
|
||||
fun copy_construct(old: test*):void {
|
||||
counter = old->counter+1
|
||||
print("copy construct from "); print(old->counter); print(" to "); println(counter)
|
||||
}
|
||||
|
||||
fun destruct():void {
|
||||
print("destruct with "); println(counter)
|
||||
}
|
||||
}
|
||||
|
||||
fun main():int {
|
||||
println(lesser(1,2))
|
||||
println(lesser(7.0,8.0))
|
||||
println(greater(1,2))
|
||||
println(greater(7.0,8.0))
|
||||
|
||||
var oddPair = make_pair(3, "hi")
|
||||
println(oddPair.first)
|
||||
println(oddPair.second)
|
||||
|
||||
println("construct")
|
||||
var test1.construct():test
|
||||
var test2.construct(100):test
|
||||
println("make_pair")
|
||||
var test_pair = make_pair(test1, test2)
|
||||
println("done")
|
||||
return 0
|
||||
}
|
||||
@@ -11,5 +11,10 @@ Copied: 1 to 2
|
||||
Destroyed: 1
|
||||
delete vector
|
||||
Destroyed: 2
|
||||
hayyy
|
||||
4.700000
|
||||
first
|
||||
first
|
||||
second
|
||||
done
|
||||
Destroyed: 0
|
||||
|
||||
@@ -70,6 +70,21 @@ fun main(): int {
|
||||
desVec->addEnd(testDestruct);
|
||||
println("delete vector")
|
||||
delete(desVec);
|
||||
|
||||
var newOne = vector("hayyy")
|
||||
println(newOne[0])
|
||||
var noParam = vector<double>()
|
||||
noParam.add(4.7)
|
||||
println(noParam[0])
|
||||
|
||||
var assignTest = vector("first")
|
||||
println(assignTest[0])
|
||||
var toAssign = vector("first")
|
||||
toAssign.add("second")
|
||||
assignTest = toAssign
|
||||
println(assignTest[0])
|
||||
println(assignTest[1])
|
||||
|
||||
println("done")
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user