Skip to content

Commit

Permalink
nitin: add some tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed Aug 23, 2024
1 parent f67dd0f commit 988eba2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contrib/nitin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ bin/nitin: $(shell $(NITLS) -M nitin.nit)
$(NITC) --semi-global nitin.nit -m readline -o bin/nitin

.PHONY: check
check:
check: all
$(NITUNIT) .
./tests.sh

.PHONY: doc
doc:
Expand Down
9 changes: 9 additions & 0 deletions contrib/nitin/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

> tests.out
for i in tests/*nit; do
echo "* $i"
printf "\n* $i\n" >> tests.out
bin/nitin < "$i" >> tests.out
done
diff -u tests.sav tests.out
14 changes: 14 additions & 0 deletions contrib/nitin/tests/attribute_initialization.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class A
var hello = "Hello"
end
var a1 = new A
print a1.hello
redef class A
var world = "World"
end
var a2 = new A
print a2.hello
print a2.world
print a1.world
a1.world = "Monde"
print a1.world
1 change: 1 addition & 0 deletions contrib/nitin/tests/hello.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print "Hello, World!"
3 changes: 3 additions & 0 deletions contrib/nitin/tests/importation.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var h = "Hello, world!"
import base64
print h.encode_base64
Empty file.
5 changes: 5 additions & 0 deletions contrib/nitin/tests/refinement.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var i = 42
redef class Int
fun foo: Int do return self + 1
end
print(i.foo)
10 changes: 10 additions & 0 deletions contrib/nitin/tests/specialization_refinement.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class A
end
class B
end
var b: Object = new B
print b isa A
redef class B
super A
end
print b isa A
6 changes: 6 additions & 0 deletions contrib/nitin/tests/variables.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var i = 42
print(i)
i += 1
print(i)
i += 1
print(i)

0 comments on commit 988eba2

Please sign in to comment.