## valgrind test code
@[ -n "$$SKIP_COVERAGE_CHECK" ] || awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
- if (ran < (ran + skip) *0.972) exit(1) }' \
+ if (ran < (ran + skip) *0.98) exit(1) }' \
coverage/oceani.mdc.gcov
coverage_oceani: oceani.c
print "z??False", z??False, "w??False", w??False
if ?w:
print "Weird?"
+ print $"-34.56", $"not-a-number"
+ print $"4i"
+ if True { pass; pass }
###### output: valvar
w??z True
z??w True
z??False True w??False False
+ -34.56 0
+ Unsupported suffix: 4i
+ 4
Next we change the value of variables
if 355/113 == pi or else +(pi - 355/113) < 0.001:
print "Close enough"
print "lower" if 355/113 < pi else "higher"
+ print "higher" if 355/113 > pi else "lower"
if pi > 3 then print "pi exceeds three"; else print "need more pie"
if (pi < 3) { print "not enough pi" } else { print "pi sufficient" }
I won't calculate 20 / 9
Close enough
higher
+ higher
pi exceeds three
pi sufficient
sum 1..10 is 55
const three ::= 3
struct foo
size:[three]number
- name:string
+ name:string = "Hello"
thing:baz
active:Boolean = True
case 2: print "two"
print "one" ++ a4[], c[]
+ x:Boolean = $"42"
+
###### output: type_err3
.tmp.code:8:12: error: expected number but variable 'c' is string
.tmp.code:7:8: info: this is where 'c' was set to string
.tmp.code:38:29: error: expected number found Boolean
.tmp.code:41:23: error: have number but need string
.tmp.code:41:29: error: string cannot provide length
+ .tmp.code:43:21: error: Can only convert string to number, not Boolean
+ .tmp.code:43:8: info: variable 'x' was set as Boolean here.
oceani: type error in program - not running.
###### test: type_err4
t->prepare_type(c, t, 1); // NOTEST
if (c->global_size & (t->align - 1))
- c->global_size = (c->global_size + t->align) & ~(t->align-1); // NOTEST
+ c->global_size = (c->global_size + t->align) & ~(t->align-1);
if (!v) {
v = &scratch;
v->type = t;
if (fl->type->print && fl->init) {
fprintf(f, " = ");
if (fl->type == Tstr)
- fprintf(f, "\""); // UNTESTED
+ fprintf(f, "\"");
print_value(fl->type, fl->init, f);
if (fl->type == Tstr)
- fprintf(f, "\""); // UNTESTED
+ fprintf(f, "\"");
}
fprintf(f, "\n");
}
struct binode *b2 = cast(binode, b->right);
left = interp_exec(c, b->left, <ype);
if (left.bool)
- rv = interp_exec(c, b2->left, &rvtype); // UNTESTED
+ rv = interp_exec(c, b2->left, &rvtype);
else
rv = interp_exec(c, b2->right, &rvtype);
}
if (t)
propagate_types(b->right, c, perr, t, 0);
else {
- t = propagate_types(b->right, c, perr, NULL, 0); // UNTESTED
- if (t) // UNTESTED
- t = propagate_types(b->left, c, perr, t, 0); // UNTESTED
+ t = propagate_types(b->right, c, perr, NULL, 0); // NOTEST
+ if (t) // NOTEST
+ t = propagate_types(b->left, c, perr, t, 0); // NOTEST
}
if (!type_compat(type, Tbool, 0))
type_err(c, "error: Comparison returns %1 but %2 expected", prog,
/* op must be string, result is number */
propagate_types(b->left, c, perr, Tstr, 0);
if (!type_compat(type, Tnum, 0))
- type_err(c, // UNTESTED
+ type_err(c,
"error: Can only convert string to number, not %1",
prog, type, 0, NULL);
*perr |= Erval;
rvtype = Tnum;
struct text tx = right.str;
- char tail[3];
+ char tail[3] = "";
int neg = 0;
if (tx.txt[0] == '-') {
- neg = 1; // UNTESTED
- tx.txt++; // UNTESTED
- tx.len--; // UNTESTED
+ neg = 1;
+ tx.txt++;
+ tx.len--;
}
if (number_parse(rv.num, tail, tx) == 0)
- mpq_init(rv.num); // UNTESTED
+ mpq_init(rv.num);
else if (neg)
- mpq_neg(rv.num, rv.num); // UNTESTED
+ mpq_neg(rv.num, rv.num);
if (tail[0])
- printf("Unsupported suffix: %.*s\n", tx.len, tx.txt); // UNTESTED
+ printf("Unsupported suffix: %.*s\n", tx.len, tx.txt);
break;
case Test:
###### print binode cases
case Block:
- if (indent < 0) {
- // simple statement
- if (b->left == NULL) // UNTESTED
- printf("pass"); // UNTESTED
- else
- print_exec(b->left, indent, bracket); // UNTESTED
- if (b->right) { // UNTESTED
- printf("; "); // UNTESTED
- print_exec(b->right, indent, bracket); // UNTESTED
- }
- } else {
- // block, one per line
- if (b->left == NULL)
- do_indent(indent, "pass\n");
- else
- print_exec(b->left, indent, bracket);
- if (b->right)
- print_exec(b->right, indent, bracket);
- }
+ // block, one per line
+ if (b->left == NULL)
+ do_indent(indent, "pass\n");
+ else
+ print_exec(b->left, indent, bracket);
+ if (b->right)
+ print_exec(b->right, indent, bracket);
break;
###### propagate binode cases