[vala/staging] tests: Add some Genie tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add some Genie tests to increase coverage
- Date: Tue, 26 Feb 2019 06:56:16 +0000 (UTC)
commit feac71ef0fd6083bebc2a4818834a4351a7e4629
Author: Alistair Thomas <astavale yahoo co uk>
Date: Mon Feb 25 21:00:51 2019 +0000
tests: Add some Genie tests to increase coverage
tests/Makefile.am | 67 +++++++++++++++++++++++++
tests/genie/class.gs | 6 +++
tests/genie/control-flow-if-do.gs | 3 ++
tests/genie/control-flow-if-else-if.gs | 7 +++
tests/genie/control-flow-if-else.gs | 7 +++
tests/genie/control-flow-if-greater-than.gs | 6 +++
tests/genie/control-flow-if-identity.gs | 6 +++
tests/genie/control-flow-if-less-than.gs | 6 +++
tests/genie/control-flow-if.gs | 5 ++
tests/genie/enum-with-keyword-values.gs | 16 ++++++
tests/genie/enum.gs | 6 +++
tests/genie/function-returns-closure.gs | 8 +++
tests/genie/function-with-argument.gs | 5 ++
tests/genie/function-with-return-value.gs | 5 ++
tests/genie/function.gs | 8 +++
tests/genie/indentation-with-spaces.gs | 3 ++
tests/genie/init.gs | 2 +
tests/genie/literal-boolean-assignment.gs | 3 ++
tests/genie/literal-boolean.gs | 5 ++
tests/genie/literal-character.gs | 3 ++
tests/genie/literal-hexadecimal.gs | 3 ++
tests/genie/literal-integer-long-long-suffix.gs | 3 ++
tests/genie/literal-integer.gs | 3 ++
tests/genie/literal-null.gs | 3 ++
tests/genie/literal-octal.gs | 3 ++
tests/genie/literal-real.gs | 4 ++
tests/genie/literal-regex.gs | 4 ++
tests/genie/literal-template-string.gs | 5 ++
tests/genie/literal-verbatim-string.gs | 5 ++
tests/genie/operator-addition.gs | 3 ++
tests/genie/operator-assignment-combined.gs | 38 ++++++++++++++
tests/genie/operator-assignment.gs | 3 ++
tests/genie/operator-bitwise-and.gs | 4 ++
tests/genie/operator-bitwise-left-shift.gs | 4 ++
tests/genie/operator-bitwise-not.gs | 4 ++
tests/genie/operator-bitwise-or.gs | 4 ++
tests/genie/operator-bitwise-right-shift.gs | 4 ++
tests/genie/operator-bitwise-xor.gs | 4 ++
tests/genie/operator-division.gs | 3 ++
tests/genie/operator-equal.gs | 6 +++
tests/genie/operator-greater-than-equal.gs | 6 +++
tests/genie/operator-less-than-equal.gs | 6 +++
tests/genie/operator-less-than.gs | 6 +++
tests/genie/operator-logical-and.gs | 5 ++
tests/genie/operator-logical-not.gs | 6 +++
tests/genie/operator-logical-or.gs | 5 ++
tests/genie/operator-modulo.gs | 3 ++
tests/genie/operator-multiply.gs | 3 ++
tests/genie/operator-not-equal.gs | 6 +++
tests/genie/operator-post-decrement.gs | 5 ++
tests/genie/operator-post-increment.gs | 5 ++
tests/genie/operator-pre-decrement.gs | 5 ++
tests/genie/operator-pre-increment.gs | 5 ++
tests/genie/operator-subtraction.gs | 3 ++
tests/genie/operator-ternary.gs | 4 ++
tests/genie/operators-greater-than.gs | 6 +++
tests/genie/preparser-and-expression.gs | 6 +++
tests/genie/preparser-elif.gs | 8 +++
tests/genie/preparser-equality-expression.gs | 6 +++
tests/genie/preparser-not.gs | 6 +++
tests/genie/preparser-or-expression.gs | 6 +++
tests/genie/preparser.gs | 15 ++++++
62 files changed, 413 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 62b56163c..1a5adc7f7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -716,6 +716,70 @@ LINUX_TESTS = \
posix/file-commandpipe.vala \
$(NULL)
+GENIE_TESTS = \
+ genie/class.gs \
+ genie/control-flow-if-do.gs \
+ genie/control-flow-if-else.gs \
+ genie/control-flow-if-else-if.gs \
+ genie/control-flow-if-greater-than.gs \
+ genie/control-flow-if.gs \
+ genie/control-flow-if-identity.gs \
+ genie/control-flow-if-less-than.gs \
+ genie/enum.gs \
+ genie/enum-with-keyword-values.gs \
+ genie/function.gs \
+ genie/function-returns-closure.gs \
+ genie/function-with-argument.gs \
+ genie/function-with-return-value.gs \
+ genie/indentation-with-spaces.gs \
+ genie/init.gs \
+ genie/literal-boolean-assignment.gs \
+ genie/literal-boolean.gs \
+ genie/literal-character.gs \
+ genie/literal-hexadecimal.gs \
+ genie/literal-integer.gs \
+ genie/literal-integer-long-long-suffix.gs \
+ genie/literal-null.gs \
+ genie/literal-octal.gs \
+ genie/literal-real.gs \
+ genie/literal-regex.gs \
+ genie/literal-template-string.gs \
+ genie/literal-verbatim-string.gs \
+ genie/operator-addition.gs \
+ genie/operator-assignment-combined.gs \
+ genie/operator-assignment.gs \
+ genie/operator-bitwise-and.gs \
+ genie/operator-bitwise-left-shift.gs \
+ genie/operator-bitwise-not.gs \
+ genie/operator-bitwise-or.gs \
+ genie/operator-bitwise-right-shift.gs \
+ genie/operator-bitwise-xor.gs \
+ genie/operator-division.gs \
+ genie/operator-equal.gs \
+ genie/operator-greater-than-equal.gs \
+ genie/operator-less-than-equal.gs \
+ genie/operator-less-than.gs \
+ genie/operator-logical-and.gs \
+ genie/operator-logical-not.gs \
+ genie/operator-logical-or.gs \
+ genie/operator-modulo.gs \
+ genie/operator-multiply.gs \
+ genie/operator-not-equal.gs \
+ genie/operator-post-decrement.gs \
+ genie/operator-post-increment.gs \
+ genie/operator-pre-decrement.gs \
+ genie/operator-pre-increment.gs \
+ genie/operators-greater-than.gs \
+ genie/operator-subtraction.gs \
+ genie/operator-ternary.gs \
+ genie/preparser-and-expression.gs \
+ genie/preparser-elif.gs \
+ genie/preparser-equality-expression.gs \
+ genie/preparser.gs \
+ genie/preparser-not.gs \
+ genie/preparser-or-expression.gs \
+ $(NULL)
+
check-TESTS: $(TESTS) $(NON_NULL_TESTS)
@EXEEXT=$(EXEEXT) CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
TEST_CFLAGS='$(TEST_CFLAGS)' CC='$(CC)' \
$(srcdir)/testrunner.sh $(TESTS)
@@ -725,11 +789,14 @@ if HAVE_LINUX
endif
@EXEEXT=$(EXEEXT) CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
TEST_CFLAGS='$(TEST_CFLAGS)' CC='$(CC)' \
VALAFLAGS="--enable-experimental-non-null" $(srcdir)/testrunner.sh $(NON_NULL_TESTS)
+ @EXEEXT=$(EXEEXT) CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
TEST_CFLAGS='$(TEST_CFLAGS)' CC='$(CC)' \
+ $(srcdir)/testrunner.sh $(GENIE_TESTS)
EXTRA_DIST = \
testrunner.sh \
$(TESTS) \
$(NON_NULL_TESTS) \
$(LINUX_TESTS) \
+ $(GENIE_TESTS) \
$(NULL)
diff --git a/tests/genie/class.gs b/tests/genie/class.gs
new file mode 100644
index 000000000..954dc874b
--- /dev/null
+++ b/tests/genie/class.gs
@@ -0,0 +1,6 @@
+init
+ var a = new Test()
+ assert( a.empty == "" )
+
+class Test
+ empty:string = ""
diff --git a/tests/genie/control-flow-if-do.gs b/tests/genie/control-flow-if-do.gs
new file mode 100644
index 000000000..cd365fecd
--- /dev/null
+++ b/tests/genie/control-flow-if-do.gs
@@ -0,0 +1,3 @@
+init
+ if true do assert( true ); return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if-else-if.gs b/tests/genie/control-flow-if-else-if.gs
new file mode 100644
index 000000000..9bf776b07
--- /dev/null
+++ b/tests/genie/control-flow-if-else-if.gs
@@ -0,0 +1,7 @@
+init
+ if false
+ assert_not_reached()
+ else if true
+ assert( true )
+ return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if-else.gs b/tests/genie/control-flow-if-else.gs
new file mode 100644
index 000000000..fbe2de3c1
--- /dev/null
+++ b/tests/genie/control-flow-if-else.gs
@@ -0,0 +1,7 @@
+init
+ if false
+ assert_not_reached()
+ else
+ assert( true )
+ return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if-greater-than.gs b/tests/genie/control-flow-if-greater-than.gs
new file mode 100644
index 000000000..2e77b0371
--- /dev/null
+++ b/tests/genie/control-flow-if-greater-than.gs
@@ -0,0 +1,6 @@
+init
+ a:int = int.MAX
+ if a > 0
+ assert( true )
+ return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if-identity.gs b/tests/genie/control-flow-if-identity.gs
new file mode 100644
index 000000000..f87563b4e
--- /dev/null
+++ b/tests/genie/control-flow-if-identity.gs
@@ -0,0 +1,6 @@
+init
+ a:string = "test"
+ if a == "test"
+ assert( a == "test" )
+ return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if-less-than.gs b/tests/genie/control-flow-if-less-than.gs
new file mode 100644
index 000000000..99c661acf
--- /dev/null
+++ b/tests/genie/control-flow-if-less-than.gs
@@ -0,0 +1,6 @@
+init
+ a:int = -1
+ if a < 0
+ assert( true )
+ return
+ assert_not_reached()
diff --git a/tests/genie/control-flow-if.gs b/tests/genie/control-flow-if.gs
new file mode 100644
index 000000000..c9da072ea
--- /dev/null
+++ b/tests/genie/control-flow-if.gs
@@ -0,0 +1,5 @@
+init
+ if true
+ assert( true )
+ return
+ assert_not_reached()
diff --git a/tests/genie/enum-with-keyword-values.gs b/tests/genie/enum-with-keyword-values.gs
new file mode 100644
index 000000000..dd39f43da
--- /dev/null
+++ b/tests/genie/enum-with-keyword-values.gs
@@ -0,0 +1,16 @@
+init
+ var a = Test.ONE
+ var b = Test.ABSTRACT
+ c:Test = Test.DEF
+ d:Test = Test.FOUR
+
+ assert( a == Test.ONE )
+ assert( b == Test.ABSTRACT )
+ assert( c == Test.DEF )
+ assert( d == Test.FOUR )
+
+enum Test
+ ONE
+ ABSTRACT
+ DEF
+ FOUR
diff --git a/tests/genie/enum.gs b/tests/genie/enum.gs
new file mode 100644
index 000000000..6f453a3bd
--- /dev/null
+++ b/tests/genie/enum.gs
@@ -0,0 +1,6 @@
+init
+ var a = Test.ONE
+ assert( a == Test.ONE )
+
+enum Test
+ ONE
diff --git a/tests/genie/function-returns-closure.gs b/tests/genie/function-returns-closure.gs
new file mode 100644
index 000000000..27742c963
--- /dev/null
+++ b/tests/genie/function-returns-closure.gs
@@ -0,0 +1,8 @@
+delegate TestFunction():bool
+
+init
+ assert( test()() == true )
+
+def test():TestFunction
+ return def()
+ return true
diff --git a/tests/genie/function-with-argument.gs b/tests/genie/function-with-argument.gs
new file mode 100644
index 000000000..f9264a8c6
--- /dev/null
+++ b/tests/genie/function-with-argument.gs
@@ -0,0 +1,5 @@
+init
+ test( 2 )
+
+def test( a:int )
+ assert( a == 2 )
diff --git a/tests/genie/function-with-return-value.gs b/tests/genie/function-with-return-value.gs
new file mode 100644
index 000000000..54a515c5f
--- /dev/null
+++ b/tests/genie/function-with-return-value.gs
@@ -0,0 +1,5 @@
+init
+ assert( test() == "passed" )
+
+def test():string
+ return "passed"
diff --git a/tests/genie/function.gs b/tests/genie/function.gs
new file mode 100644
index 000000000..c78c71d55
--- /dev/null
+++ b/tests/genie/function.gs
@@ -0,0 +1,8 @@
+global:int = 0
+
+init
+ test()
+ assert( global == 1 )
+
+def test()
+ global += 1
diff --git a/tests/genie/indentation-with-spaces.gs b/tests/genie/indentation-with-spaces.gs
new file mode 100644
index 000000000..e3c7652a6
--- /dev/null
+++ b/tests/genie/indentation-with-spaces.gs
@@ -0,0 +1,3 @@
+[indent = 2]
+init
+ assert( true )
diff --git a/tests/genie/init.gs b/tests/genie/init.gs
new file mode 100644
index 000000000..cd9eb2a14
--- /dev/null
+++ b/tests/genie/init.gs
@@ -0,0 +1,2 @@
+init
+ assert( true )
diff --git a/tests/genie/literal-boolean-assignment.gs b/tests/genie/literal-boolean-assignment.gs
new file mode 100644
index 000000000..8c8938054
--- /dev/null
+++ b/tests/genie/literal-boolean-assignment.gs
@@ -0,0 +1,3 @@
+init
+ a:bool = true
+ assert( a == true )
diff --git a/tests/genie/literal-boolean.gs b/tests/genie/literal-boolean.gs
new file mode 100644
index 000000000..3935452bc
--- /dev/null
+++ b/tests/genie/literal-boolean.gs
@@ -0,0 +1,5 @@
+init
+ if true
+ assert( true )
+ if !false
+ assert( !false )
diff --git a/tests/genie/literal-character.gs b/tests/genie/literal-character.gs
new file mode 100644
index 000000000..f31126969
--- /dev/null
+++ b/tests/genie/literal-character.gs
@@ -0,0 +1,3 @@
+init
+ a:char = 'a'
+ assert( a == 'a' )
diff --git a/tests/genie/literal-hexadecimal.gs b/tests/genie/literal-hexadecimal.gs
new file mode 100644
index 000000000..1ac14989d
--- /dev/null
+++ b/tests/genie/literal-hexadecimal.gs
@@ -0,0 +1,3 @@
+init
+ var a = 0x10
+ assert( a == 16 )
diff --git a/tests/genie/literal-integer-long-long-suffix.gs b/tests/genie/literal-integer-long-long-suffix.gs
new file mode 100644
index 000000000..69b580eb5
--- /dev/null
+++ b/tests/genie/literal-integer-long-long-suffix.gs
@@ -0,0 +1,3 @@
+init
+ a:int64 = 1234567890123456789LL
+ assert( a == 1234567890123456789 )
diff --git a/tests/genie/literal-integer.gs b/tests/genie/literal-integer.gs
new file mode 100644
index 000000000..eb1a20d0b
--- /dev/null
+++ b/tests/genie/literal-integer.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 101
+ assert( a == 101 )
diff --git a/tests/genie/literal-null.gs b/tests/genie/literal-null.gs
new file mode 100644
index 000000000..dc3f4b4f3
--- /dev/null
+++ b/tests/genie/literal-null.gs
@@ -0,0 +1,3 @@
+init
+ test:string? = null
+ assert( test == null )
diff --git a/tests/genie/literal-octal.gs b/tests/genie/literal-octal.gs
new file mode 100644
index 000000000..14068cadf
--- /dev/null
+++ b/tests/genie/literal-octal.gs
@@ -0,0 +1,3 @@
+init
+ var a = 022
+ assert( a == 18 )
diff --git a/tests/genie/literal-real.gs b/tests/genie/literal-real.gs
new file mode 100644
index 000000000..762431da8
--- /dev/null
+++ b/tests/genie/literal-real.gs
@@ -0,0 +1,4 @@
+init
+ a:double = 1.1
+ b:double = 1.2
+ assert( a + b > 2 )
diff --git a/tests/genie/literal-regex.gs b/tests/genie/literal-regex.gs
new file mode 100644
index 000000000..be990285a
--- /dev/null
+++ b/tests/genie/literal-regex.gs
@@ -0,0 +1,4 @@
+init
+ var a = /^test/
+ var b = "test string"
+ assert( a.match( b ))
diff --git a/tests/genie/literal-template-string.gs b/tests/genie/literal-template-string.gs
new file mode 100644
index 000000000..87e75ae92
--- /dev/null
+++ b/tests/genie/literal-template-string.gs
@@ -0,0 +1,5 @@
+init
+ var a = "test"
+ var b = 100
+ var c = @"$( a )$b"
+ assert( c == "test100" )
diff --git a/tests/genie/literal-verbatim-string.gs b/tests/genie/literal-verbatim-string.gs
new file mode 100644
index 000000000..56ac97618
--- /dev/null
+++ b/tests/genie/literal-verbatim-string.gs
@@ -0,0 +1,5 @@
+init
+ var a = """multi
+line
+string"""
+ assert( a == "multi\nline\nstring" )
diff --git a/tests/genie/operator-addition.gs b/tests/genie/operator-addition.gs
new file mode 100644
index 000000000..4faaee3d4
--- /dev/null
+++ b/tests/genie/operator-addition.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 1 + 1
+ assert( a == 2 )
diff --git a/tests/genie/operator-assignment-combined.gs b/tests/genie/operator-assignment-combined.gs
new file mode 100644
index 000000000..f031b66b2
--- /dev/null
+++ b/tests/genie/operator-assignment-combined.gs
@@ -0,0 +1,38 @@
+init
+ a:int = 2
+
+ a += 1
+ assert( a == 3 )
+
+ a -= 1
+ assert( a == 2 )
+
+ a /= 2
+ assert( a == 1 )
+
+ a *= 2
+ assert( a == 2 )
+
+ a %= 2
+ assert( a == 0 )
+
+ a++
+ assert( a == 1 )
+
+ a--
+ assert( a == 0 )
+
+ a |= 1
+ assert( a == 1 )
+
+ a &= 3
+ assert( a == 1 )
+
+ a ^= 3
+ assert( a == 2 )
+
+ a >>= 1
+ assert( a == 1 )
+
+ a <<= 1
+ assert( a == 2 )
diff --git a/tests/genie/operator-assignment.gs b/tests/genie/operator-assignment.gs
new file mode 100644
index 000000000..c56fe1fca
--- /dev/null
+++ b/tests/genie/operator-assignment.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 1
+ assert( a == 1 )
diff --git a/tests/genie/operator-bitwise-and.gs b/tests/genie/operator-bitwise-and.gs
new file mode 100644
index 000000000..c55684f91
--- /dev/null
+++ b/tests/genie/operator-bitwise-and.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = a & 7
+ assert( b == 5 )
diff --git a/tests/genie/operator-bitwise-left-shift.gs b/tests/genie/operator-bitwise-left-shift.gs
new file mode 100644
index 000000000..718fb14ba
--- /dev/null
+++ b/tests/genie/operator-bitwise-left-shift.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = a << 1
+ assert( b == 10 )
diff --git a/tests/genie/operator-bitwise-not.gs b/tests/genie/operator-bitwise-not.gs
new file mode 100644
index 000000000..0ccba0490
--- /dev/null
+++ b/tests/genie/operator-bitwise-not.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = ~a
+ assert( b == -6 )
diff --git a/tests/genie/operator-bitwise-or.gs b/tests/genie/operator-bitwise-or.gs
new file mode 100644
index 000000000..1c145da57
--- /dev/null
+++ b/tests/genie/operator-bitwise-or.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = a | 3
+ assert( b == 7 )
diff --git a/tests/genie/operator-bitwise-right-shift.gs b/tests/genie/operator-bitwise-right-shift.gs
new file mode 100644
index 000000000..c73f3d72f
--- /dev/null
+++ b/tests/genie/operator-bitwise-right-shift.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = a >> 1
+ assert( b == 2 )
diff --git a/tests/genie/operator-bitwise-xor.gs b/tests/genie/operator-bitwise-xor.gs
new file mode 100644
index 000000000..9eaab21fb
--- /dev/null
+++ b/tests/genie/operator-bitwise-xor.gs
@@ -0,0 +1,4 @@
+init
+ a:int = 5
+ var b = a ^ 7
+ assert( b == 2 )
diff --git a/tests/genie/operator-division.gs b/tests/genie/operator-division.gs
new file mode 100644
index 000000000..d9ff08059
--- /dev/null
+++ b/tests/genie/operator-division.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 100 / 10
+ assert( a == 10 )
diff --git a/tests/genie/operator-equal.gs b/tests/genie/operator-equal.gs
new file mode 100644
index 000000000..ce27abcc8
--- /dev/null
+++ b/tests/genie/operator-equal.gs
@@ -0,0 +1,6 @@
+init
+ var a = "test"
+ if a == "test"
+ assert( a == "test" )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-greater-than-equal.gs b/tests/genie/operator-greater-than-equal.gs
new file mode 100644
index 000000000..3a3e39f31
--- /dev/null
+++ b/tests/genie/operator-greater-than-equal.gs
@@ -0,0 +1,6 @@
+init
+ var a = 10
+ if a >= 10
+ assert( a >= 10 )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-less-than-equal.gs b/tests/genie/operator-less-than-equal.gs
new file mode 100644
index 000000000..63b1e867b
--- /dev/null
+++ b/tests/genie/operator-less-than-equal.gs
@@ -0,0 +1,6 @@
+init
+ var a = 10
+ if a <= 10
+ assert( a <= 10 )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-less-than.gs b/tests/genie/operator-less-than.gs
new file mode 100644
index 000000000..7b51113de
--- /dev/null
+++ b/tests/genie/operator-less-than.gs
@@ -0,0 +1,6 @@
+init
+ var a = 10
+ if a < 11
+ assert( a < 11 )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-logical-and.gs b/tests/genie/operator-logical-and.gs
new file mode 100644
index 000000000..23476acbc
--- /dev/null
+++ b/tests/genie/operator-logical-and.gs
@@ -0,0 +1,5 @@
+init
+ a:bool = true
+ b:bool = true
+ assert( a and b )
+ assert( a && b )
diff --git a/tests/genie/operator-logical-not.gs b/tests/genie/operator-logical-not.gs
new file mode 100644
index 000000000..4c58b6a26
--- /dev/null
+++ b/tests/genie/operator-logical-not.gs
@@ -0,0 +1,6 @@
+init
+ a:bool = false
+ if !a
+ assert( !a )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-logical-or.gs b/tests/genie/operator-logical-or.gs
new file mode 100644
index 000000000..38271697f
--- /dev/null
+++ b/tests/genie/operator-logical-or.gs
@@ -0,0 +1,5 @@
+init
+ a:bool = false
+ b:bool = true
+ assert( a or b )
+ assert( a || b )
diff --git a/tests/genie/operator-modulo.gs b/tests/genie/operator-modulo.gs
new file mode 100644
index 000000000..e96f6cdf3
--- /dev/null
+++ b/tests/genie/operator-modulo.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 11 % 10
+ assert( a == 1 )
diff --git a/tests/genie/operator-multiply.gs b/tests/genie/operator-multiply.gs
new file mode 100644
index 000000000..40353e3a9
--- /dev/null
+++ b/tests/genie/operator-multiply.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 1 * 2
+ assert( a == 2 )
diff --git a/tests/genie/operator-not-equal.gs b/tests/genie/operator-not-equal.gs
new file mode 100644
index 000000000..a7fa160c4
--- /dev/null
+++ b/tests/genie/operator-not-equal.gs
@@ -0,0 +1,6 @@
+init
+ var a = "not"
+ if a != "test"
+ assert( a != "test" )
+ else
+ assert_not_reached()
diff --git a/tests/genie/operator-post-decrement.gs b/tests/genie/operator-post-decrement.gs
new file mode 100644
index 000000000..c11b1f8ac
--- /dev/null
+++ b/tests/genie/operator-post-decrement.gs
@@ -0,0 +1,5 @@
+init
+ a:int = 1
+ var b = a--
+ assert( a == 0 )
+ assert( b == 1 )
diff --git a/tests/genie/operator-post-increment.gs b/tests/genie/operator-post-increment.gs
new file mode 100644
index 000000000..f13e61bcc
--- /dev/null
+++ b/tests/genie/operator-post-increment.gs
@@ -0,0 +1,5 @@
+init
+ a:int = 1
+ var b = a++
+ assert( a == 2 )
+ assert( b == 1 )
diff --git a/tests/genie/operator-pre-decrement.gs b/tests/genie/operator-pre-decrement.gs
new file mode 100644
index 000000000..bf46485e9
--- /dev/null
+++ b/tests/genie/operator-pre-decrement.gs
@@ -0,0 +1,5 @@
+init
+ a:int = 1
+ var b = --a
+ assert( a == 0 )
+ assert( b == 0 )
diff --git a/tests/genie/operator-pre-increment.gs b/tests/genie/operator-pre-increment.gs
new file mode 100644
index 000000000..b74a7a2a0
--- /dev/null
+++ b/tests/genie/operator-pre-increment.gs
@@ -0,0 +1,5 @@
+init
+ a:int = 1
+ var b = ++a
+ assert( a == 2 )
+ assert( b == 2 )
diff --git a/tests/genie/operator-subtraction.gs b/tests/genie/operator-subtraction.gs
new file mode 100644
index 000000000..aa5beed5f
--- /dev/null
+++ b/tests/genie/operator-subtraction.gs
@@ -0,0 +1,3 @@
+init
+ a:int = 2 - 1
+ assert( a == 1 )
diff --git a/tests/genie/operator-ternary.gs b/tests/genie/operator-ternary.gs
new file mode 100644
index 000000000..f7d89e522
--- /dev/null
+++ b/tests/genie/operator-ternary.gs
@@ -0,0 +1,4 @@
+init
+ a:bool = false
+ b:string = a ? "true" : "false"
+ assert( b == "false")
diff --git a/tests/genie/operators-greater-than.gs b/tests/genie/operators-greater-than.gs
new file mode 100644
index 000000000..ec19ee8e4
--- /dev/null
+++ b/tests/genie/operators-greater-than.gs
@@ -0,0 +1,6 @@
+init
+ var a = 10
+ if a > 9
+ assert( a > 9 )
+ else
+ assert_not_reached()
diff --git a/tests/genie/preparser-and-expression.gs b/tests/genie/preparser-and-expression.gs
new file mode 100644
index 000000000..b16f99d23
--- /dev/null
+++ b/tests/genie/preparser-and-expression.gs
@@ -0,0 +1,6 @@
+init
+#if TEST && FOO
+ assert_not_reached()
+#else
+ assert( true )
+#endif
diff --git a/tests/genie/preparser-elif.gs b/tests/genie/preparser-elif.gs
new file mode 100644
index 000000000..e722072e6
--- /dev/null
+++ b/tests/genie/preparser-elif.gs
@@ -0,0 +1,8 @@
+init
+#if TEST
+ assert_not_reached()
+#elif VALA_0_16
+ assert( true )
+#else
+ assert_not_reached()
+#endif
diff --git a/tests/genie/preparser-equality-expression.gs b/tests/genie/preparser-equality-expression.gs
new file mode 100644
index 000000000..fb50dd736
--- /dev/null
+++ b/tests/genie/preparser-equality-expression.gs
@@ -0,0 +1,6 @@
+init
+#if THIS_IS_NOT_SET == true
+ assert_not_reached()
+#else
+ assert( true )
+#endif
diff --git a/tests/genie/preparser-not.gs b/tests/genie/preparser-not.gs
new file mode 100644
index 000000000..80ee037c6
--- /dev/null
+++ b/tests/genie/preparser-not.gs
@@ -0,0 +1,6 @@
+init
+#if !VALA_0_16
+ assert_not_reached()
+#else
+ assert( true )
+#endif
diff --git a/tests/genie/preparser-or-expression.gs b/tests/genie/preparser-or-expression.gs
new file mode 100644
index 000000000..ba8713c57
--- /dev/null
+++ b/tests/genie/preparser-or-expression.gs
@@ -0,0 +1,6 @@
+init
+#if TEST || FOO
+ assert_not_reached()
+#else
+ assert( true )
+#endif
diff --git a/tests/genie/preparser.gs b/tests/genie/preparser.gs
new file mode 100644
index 000000000..ab4d40120
--- /dev/null
+++ b/tests/genie/preparser.gs
@@ -0,0 +1,15 @@
+init
+ result:string = ""
+#if VALA_0_16
+ result = "0.16+"
+#else
+ result = "<0.16"
+#endif
+
+ assert( result != "" )
+
+#if VALA_0_16
+ assert( result == "0.16+" )
+#else
+ assert( result == "<0.16" )
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]