Files
secondo/Tests/Testspecs/standard.test

522 lines
8.5 KiB
Plaintext
Raw Normal View History

2026-01-23 17:03:45 +08:00
# Check basic SECONDO commands
#
# Feb 2005, M. Spiekermann
#
delete database basic_cmd;
#setup basic_cmd
# if a command between the SETUP directive and the first
# TESTCASE directive fails, then the whole test has failed
# and we immediately skip to the teardown
# (the whole test does not make sense anymore if the
# SETUP has failed)
create database basic_cmd;
#testcase list algebras
#yields success
list algebras;
#testcase list operators
#yields success
list operators;
#testcase list type constructors
#yields success
list type constructors;
#testcase list objects;
#yields error
list objects;
#testcase open database
#yields success
open database basic_cmd;
let myrel = [const rel(tuple([No: int])) value ((1))];
let ten = intstream(1,10) namedtransformstream[No] consume;
let thousand = intstream(1,1000) namedtransformstream[No] consume;
#testcase list objects;
#yields success
list objects;
#testcase list types;
#yields success
list types;
# Test standard algebra
# Operations with int and real
#testcase create a real object with let;
#yields success
let x = -1.2
#testcase create a real object with let;
#yields success
let y = [const real value -.2];
#testcase create a int object with let;
#yields success
let a = 7
#testcase create a int object with let;
#yields success
let b = [const int value -4];
#testcase create a int object with let;
#yields success
let c = [const int value 2];
#testcase a+b
#yields (int 3)
query a + b
#testcase a-b
#yields (int 11)
query a - b
#testcase a*b
#yields (int -28)
query a * b
#testcase a/c
#yields (real 3.5)
query a / c
#testcase a mod c
#yields (int 1)
query a mod c
#testcase a div c
#yields (int 3)
query a div c
# Integer Comparisons
#testcase a>b
#yields (bool TRUE)
query a > b
#testcase a>=b
#yields (bool TRUE)
query a >= b
#testcase b>a
#yields (bool FALSE)
query b > a
#testcase b<=a
#yields (bool TRUE)
query b <= a
#testcase a=a
#yields (bool TRUE)
query a = a;
#testcase a>=a
#yields (bool TRUE)
query a >= a;
#testcase a<=a
#yields (bool TRUE)
query a <= a;
#testcase a # a
#yields (bool FALSE)
query a # a;
#testcase a # b
#yields (bool TRUE)
query a # b;
# Mixed Integer/Real Comparisons
#testcase int/real-1
#yields (bool TRUE)
query 1.0 < 2;
#testcase int/real-2
#yields (bool FALSE)
query 3.1 < 2;
#testcase int/real-1
#yields (bool TRUE)
query 1.0 <= 2;
#testcase int/real-2
#yields (bool FALSE)
query 3.1 <= 2;
#testcase int/real-3
#yields (bool TRUE)
query 2.1 > 2;
#testcase int/real-4
#yields (bool FALSE)
query 2.1 > 3;
#testcase int/real-3
#yields (bool TRUE)
query 2.1 >= 2;
#testcase int/real-4
#yields (bool FALSE)
query 2.1 >= 3;
#testcase int/real-5
#yields (bool TRUE)
query 3.0 = 3;
#testcase int/real-6
#yields (bool FALSE)
query 3.0 # 3;
# real/int Comparisons
#testcase int/real-1
#yields (bool TRUE)
query 1 < 2.0;
#testcase int/real-2
#yields (bool FALSE)
query 3 < 2.1;
#testcase int/real-1
#yields (bool TRUE)
query 1 <= 2.2;
#testcase int/real-2
#yields (bool FALSE)
query 3 <= 2.4;
#testcase int/real-3
#yields (bool TRUE)
query 2 > 1.9;
#testcase int/real-4
#yields (bool FALSE)
query 2 > 3.3;
#testcase int/real-3
#yields (bool TRUE)
query 2 >= 1.9;
#testcase int/real-4
#yields (bool FALSE)
query 2 >= 3.1;
#testcase int/real-5
#yields (bool TRUE)
query 3 = 3.0;
#testcase int/real-6
#yields (bool FALSE)
query 3 # 3.0;
#testcase between-1
#yields (bool TRUE)
query 4 between[3, 5];
#testcase between-2
#yields (bool TRUE)
query 4.2 between[3.3, 5.1];
#testcase between-3
#yields (bool TRUE)
query "ABC" between["A", "ABC"];
#testcase randint
#yields (bool TRUE)
query randint (9) <= 8
#testcase randint
#yields (bool TRUE)
query randint (9) >= 0
#testcase maxrand
#yields success
query randmax()
#testcase nextseq
#yields (int 0)
query seqnext()
#testcase initseq
#yields success
query seqinit(100)
#testcase nextseq
#yields (int 100)
query seqnext()
#testcase log
#yields (int 8)
query log (256)
# Boolean Operations
#testcase not
#yields (bool FALSE)
query not ( 4=4 )
#testcase and
#yields (bool TRUE)
query (8 = 8) and (3 < 4)
#testcase or
#yields (bool TRUE)
query (3 <= 4) or ("hotel" > "house")
# String Operations
#testcase starts 1
#yields (bool TRUE)
query "starts" starts "st"
#testcase starts 2
#yields (bool FALSE)
query "starts" starts "xv"
#testcase contains 1
#yields (bool TRUE)
query "starts" contains "rt"
#testcase contains 2
#yields (bool FALSE)
query "starts" contains "xc"
#testcase substr
#yields (bool TRUE)
query substr("test",2,3) = "es"
#testcase strcmp-1
#yields (bool TRUE)
query "Abc" = "Abc";
#testcase strcmp-2
#yields (bool FALSE)
query "Abc" = "ABC";
#testcase strcmp-3
#yields (bool FALSE)
query "Abc" # "Abc";
#testcase strcmp-4
#yields (bool TRUE)
query "Abc" # "ABC";
#testcase strcmp-5
#yields (bool FALSE)
query "house" < "hotel"
#testcase strcmp-6
#yields (bool TRUE)
query "house" > "hotel"
#testcase plusplus
#yields (bool TRUE)
query "hello"++ = "hellp"
#testcase ldistance
#yields (int 1)
query ldistance("second", "secondo")
#testcase isempty
#yields (bool FALSE)
query isempty(1)
#testcase intersection
#yields (int 3)
query intersection(3 , 3)
#testcase minus
#yields (int 4)
query 4 minus 3
#testcase ifthenelse
#yields (string "true")
query ifthenelse( 3 < 4 , "true" , "false")
#testcase ifthenelse_undef
#yields (string undefined)
query ifthenelse( [const bool value undefined] , "true" , "false")
#testcase ifthenelse_stream
#yields (int 999999)
query ifthenelse( 3 < 4 , intstream(1,999999) ,1 feed) count;
#testcase ifthenelse_stream_undef
#yields (int 0)
query ifthenelse( [const bool value undefined] , intstream(1,999999) ,1 feed) count;
#testcase ifthenelse2_rel
#yields (int 1000)
query ifthenelse2( 3 > 4 , ten, thousand) count;
#testcase ifthenelse2_trel
#yields (int 1000)
query ifthenelse2( 3 > 4 , ten feed tconsume , thousand feed tconsume) count;
#testcase setoption
#yields (bool undefined)
query setoption ("unknown", 3)
#testcase hashvalue
#yields (int 4)
query hashvalue(4, 6)
###testcase elapsedtime
###yields success
##query (5 + 6) elapsedtime
#testcase relcount
#yields (int 1)
query "myrel" relcount
#testcase relcount2
#yields (int 1)
query "myrel" relcount2
#testcase keywords1
#yields (int 4)
query "this is a test" keywords count;
#testcase keywords2
#yields ((rel(tuple((Elem string))))(("this")("is")("a")("test")))
query "this is a test" keywords transformstream consume;
#tolerance_real 0.000001
#testcase round-1
#yields (real 1.12346)
query round(1.123456789, 5)
#testcase round-2
#yields (real 4300.0)
query round(4321.123, -2)
#testcase int2real-1
#yields (real -2.0)
query int2real(-2)
#testcase int2real-2
#yields (real 77.0)
query int2real(77)
#testcase real2int-1
#yields (int -1)
query real2int(-1.2)
#testcase real2int-2
#yields (int 789)
query real2int(789.7)
#testcase int2bool-1
#yields (bool TRUE)
query int2bool(-5)
#testcase int2bool-2
#yields (bool FALSE)
query int2bool(0)
#testcase bool2int-1
#yields (int 0)
query bool2int(FALSE)
#testcase bool2int-2
#yields (int 1)
query bool2int(TRUE)
#testcase ceil
#yields (real -1.0)
query ceil(-1.2)
#testcase floor
#yields (real -2.0)
query floor(-1.2)
#testcase isdefined_int_true
#yields (bool TRUE)
query isdefined(-12)
#testcase isdefined_int_false
#yields (bool FALSE)
query isdefined([const int value undefined])
#testcase isdefined_real_true
#yields (bool TRUE)
query isdefined(-676.782)
#testcase isdefined_real_false
#yields (bool FALSE)
query isdefined( 1.0 / 0)
#testcase isdefined_string_true
#yields (bool TRUE)
query isdefined("")
#testcase isdefined_string_false
#yields (bool FALSE)
query isdefined([const string value undefined])
#testcase isdefined_bool_true
#yields (bool TRUE)
query isdefined(FALSE)
#testcase isdefined_bool_false
#yields (bool FALSE)
query isdefined([const bool value undefined])
#testcase compare_int_<
#yields (int -1)
query compare(1,2)
#testcase compare_int_>
#yields (int 1)
query compare(6956,-6542)
#testcase compare_int=
#yields (int 0)
query compare(-654,-654)
#testcase compare_int_undef=
#yields (int 0)
query compare([const int value undefined],[const int value undefined])
#testcase compare_int_undef<
#yields (int 1)
query compare(-6876,[const int value undefined])
#testcase compare_int_undef>
#yields (int -1)
query compare([const int value undefined],6876)
#testcase compare_int_undef=
#yields (int 0)
query compare([const int value undefined],[const int value undefined])
#testcase coverage
#coverage StandardAlgebra
# the TEARDOWN directive is followed by commands which
# should be executed after the execution of all TESTCASES
#teardown
close database;
delete database basic_cmd;