0.2.4 • Published 10 years ago

c0t v0.2.4

Weekly downloads
3
License
Unlicense
Repository
github
Last release
10 years ago

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
0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago