X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;h=dde99bf37b55db6141c8ae241c6b2d97b1d682a3;hb=dd984d3a50a51eaadea073b3bdc7d7ebef6def2c;hp=6ea120447b33dd3134339efcb819776d6eff89c9;hpb=9da671b6631e648e82b07c323bfa9315c6c8c5f2;p=ocean diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 6ea1204..dde99bf 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -84,7 +84,7 @@ arguments separated from the name by commas. For each test, there is a section coverage/oceani.mdc.gcov @rm -f .tmp* - @for T in $(oceani_tests); do \ + @[ -n "$$SKIP_VALGRIND" ] || for T in $(oceani_tests); do \ echo -n "Valgrind $$T.. "; \ i="$$IFS"; IFS=,; set $$T; IFS="$$i"; t=$$1; shift; \ if ! valgrind --error-exitcode=1 --log-file=.tmp.valg ./oceani --section "test: $$t" oceani-tests.mdc $${1+"$$@"} \ @@ -282,9 +282,10 @@ Here I break it into two parts, keeping the array code separate. ###### test: sayhello - program As Bs astr bbools: - A := $As; B := $Bs - bbool := bbools == "True" + program ac av: + A := $av[1]; B := $av[2] + astr := av[3] + bbool := av[ac-1] == "True" print "Hello World, what lovely oceans you have!" /* When a variable is defined in both branches of an 'if', * and used afterwards, the variables are merged. @@ -532,11 +533,15 @@ ad-hoc things array related. bools[1] = strings[2] <= "there" for i:=0; then i=i+1; while i<5: - print '', bools[i], + j ::= i + ra:[j]number + ra[i-1] = i*i + ra[6] = 42 // mustn't crash + print '', bools[i], ra[j-1], print ###### output: arrays - False True False False False + False 0 True 1 False 4 False 9 False 16 ## Structures @@ -547,10 +552,11 @@ Time to test if structure declarations and accesses work correctly. ###### test: structs + const three ::= 3 struct foo - size:[3]number + size:[three]number name:string - active:Boolean + active:Boolean = True struct baz { a:number; b:Boolean; } @@ -566,7 +572,8 @@ Time to test if structure declarations and accesses work correctly. info[i].name = nm info[i].size[0] = i*i - info[i].active = nm == "jane" + if nm != "jane": + info[i].active = False for i:=0; then i=i+1; while i < 4: print info[i].name, info[i].active, info[i].size[0] @@ -787,7 +794,7 @@ various places that `type_err()` are called. oceani: type error in program - not running. ###### test list - oceani_failing_tests += type_err_const type_err_const1 + oceani_failing_tests += type_err_const type_err_const1 missing_program ###### test: type_err_const const @@ -818,6 +825,13 @@ various places that `type_err()` are called. .tmp.code:3:12: Syntax error in constant: : .tmp.code:4:12: Syntax error in constant: : +###### test: missing_program + const + foo::="bar" + +###### output: missing_program + oceani: no program found. + ## Test erroneous command line args To improve coverage, we want to test correct handling of strange command