|
From: <ha...@us...> - 2008-07-28 00:14:37
|
Revision: 2102
http://cogkit.svn.sourceforge.net/cogkit/?rev=2102&view=rev
Author: hategan
Date: 2008-07-28 00:14:35 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
updated tests
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/tests/run
branches/karajan2/src/cog/modules/karajan2/tests/types.k
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/tests/lists.k
branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k
branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k
branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected
Added: branches/karajan2/src/cog/modules/karajan2/tests/lists.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/lists.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/lists.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,17 @@
+import(sys)
+import(list)
+
+l1 := List(Integer)(1, 2, 3, 4)
+
+print(l1)
+print(first(l1) + last(l1))
+print(butFirst(l1))
+print(butLast(l1))
+print(butFirst(butLast(l1)))
+print(concat(butFirst(l1), butLast(l1)))
+print(subList(l1, 2))
+print(subList(l1, 1, 3))
+
+l2 := List(?)(1, "abc", 3.0)
+
+print(l2)
Added: branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/lists.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,9 @@
+[1, 2, 3, 4]
+5
+[2, 3, 4]
+[1, 2, 3]
+[2, 3]
+[2, 3, 4, 1, 2, 3]
+[3, 4]
+[2, 3]
+[1, abc, 3.0]
Added: branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,23 @@
+import(sys)
+import(string)
+
+Tree := type(value, left:Tree, right:Tree) {
+ toString := function() {
+ concat(
+ value, "["
+ if (left != nil, (left::toString(), ", "))
+ if (right != nil, right::toString())
+ "]"
+ )
+ }
+}
+
+t := Tree("a",
+ Tree("b"
+ nil
+ Tree("c", nil, nil)
+ )
+ Tree("d", nil, nil)
+)
+
+print(t::toString())
\ No newline at end of file
Added: branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/recursive-type.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1 @@
+a[b[c[]], d[]]
Modified: branches/karajan2/src/cog/modules/karajan2/tests/run
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/run 2008-07-28 00:14:14 UTC (rev 2101)
+++ branches/karajan2/src/cog/modules/karajan2/tests/run 2008-07-28 00:14:35 UTC (rev 2102)
@@ -2,7 +2,7 @@
# make up a tc.data file
-COUNT=4
+COUNT=2
checkOutput() {
for e in $EXPECTEDS; do
@@ -67,12 +67,9 @@
else
echo Running test $t
echo expecting $EXPECTEDS
- for i in `seq $COUNT`; do
- k -intermediate ${t}.k > "$testfn.out" 2>&1
- if [ "$?" -ne "0" ]; then echo "K RETURN CODE NON-ZERO"; exit 1; fi
- checkOutput
- echo -n "."
- done
+
+ test-runner ${t}.k $COUNT
+ if [ "$?" -ne "0" ]; then echo "K RETURN CODE NON-ZERO"; exit 1; fi
echo
fi
@@ -83,7 +80,7 @@
done
if [ "$SUB" == "" ]; then
- echo All language behaviour tests passed
+ echo All tests passed
fi
exit 0
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,24 @@
+import(sys)
+
+integerf := function() {
+ Integer
+}
+
+mirror := function(t:Type) {
+ t
+}
+
+x:Integer = 1
+y:integerf() = 1
+z:mirror(Integer) = 1
+
+myInt := mirror(Integer)
+w:myInt = 1
+
+print(mirror)
+print(x)
+print(y)
+print(z)
+print(myInt)
+print(w)
+
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,6 @@
+Type -> Type
+1
+1
+1
+Integer
+1
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,17 @@
+import(sys)
+
+f := function(t:Type) {
+ type(x:t, y:t) {
+ }
+}
+
+ti := f(Integer)
+tii := ti(1, 2)
+
+print(tii::x + tii::y)
+
+tr := f(Real)
+trr := tr(1.1, 2.2)
+
+print(trr::x + trr::y)
+
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun2.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,2 @@
+3
+3.3000000000000003
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,9 @@
+import(sys)
+
+f := function(x: Integer | Real) {
+ print(x)
+}
+
+print(f)
+f(1)
+f(2.0)
\ No newline at end of file
Added: branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/tests/type-fun3.k.expected 2008-07-28 00:14:35 UTC (rev 2102)
@@ -0,0 +1,3 @@
+Integer | Real -> |stdout:?|
+1
+2.0
Modified: branches/karajan2/src/cog/modules/karajan2/tests/types.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/tests/types.k 2008-07-28 00:14:14 UTC (rev 2101)
+++ branches/karajan2/src/cog/modules/karajan2/tests/types.k 2008-07-28 00:14:35 UTC (rev 2102)
@@ -1,22 +1,22 @@
import(sys)
-Address := type(
+Address:Type = type(
number:Integer
street:String
city:String
state:String
- zip:Integer
-) {
+ zip:Integer) {
+
toString := function() {
"{number} {street}\n{city}, {state} {zip}"
}
}
-Person := type(
+Person:Type = type(
name:String
age:Integer
- address:Address
-) {
+ address:Address) {
+
toString := function() {
"{name}, {age}\n" + address::toString()
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|