c0t
v0.2.4
Published
Write tests for C0.
Downloads
7
Readme
c0t
Write tests for C0.
Install
> npm i -g c0t
Describe
power.c0:
int POW(int b, int e)
//@requires e >= 0;
{...}
int power(int x, int y)
//@requires y >= 0;
//@ensures \result == POW(x,y);
{...}
power.c0t:
#use "power.c0"
describe "power" {
it "should return its first argument raised to the power of its second argument" {
assert power(2, 3) == 8;
assert power(4, 2) == 16;
}
it "should return 1 when the exponent is 0" {
assert power(2, 0) == 1;
assert power(5, 0) == 1;
}
it "should accept negative bases" {
assert_ok power(-4, 3);
assert_ok {
power(-3, 0);
}
}
it "should not accept negative exponents" {
assert_err power(2, -1);
assert_err {
power(0, -3);
}
}
}
Test
> c0t power.c0t
Repeat
> c0t --live power.c0t