|
|
@ -1,127 +1,127 @@ |
|
|
|
#include "ptlisp-test.h" |
|
|
|
#include "ptlisp-test.h" |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(addition_zero_args_test) { |
|
|
|
START_TEST(addition_zero_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(NIL)), 0); |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(NIL, NIL)), 0); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(addition_one_args_test) { |
|
|
|
START_TEST(addition_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(LIST(number(69)))), 69); |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(LIST(number(69)), NIL)), 69); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(addition_many_args_test) { |
|
|
|
START_TEST(addition_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(LIST(number(69), number(420)))), 489); |
|
|
|
ck_assert_double_eq(NUMBER(add_fn(LIST(number(69), number(420)), NIL)), 489); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(substraction_zero_args_test) { |
|
|
|
START_TEST(substraction_zero_args_test) { |
|
|
|
ck_assert_uint_eq(sub_fn(NIL), UNDEFINED); |
|
|
|
ck_assert_uint_eq(sub_fn(NIL, NIL), UNDEFINED); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(substraction_one_args_test) { |
|
|
|
START_TEST(substraction_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(sub_fn(LIST(number(69)))), -69); |
|
|
|
ck_assert_double_eq(NUMBER(sub_fn(LIST(number(69)), NIL)), -69); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(substraction_many_args_test) { |
|
|
|
START_TEST(substraction_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(sub_fn(LIST(number(69), number(420)))), -351); |
|
|
|
ck_assert_double_eq(NUMBER(sub_fn(LIST(number(69), number(420)), NIL)), -351); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(multiplication_zero_args_test) { |
|
|
|
START_TEST(multiplication_zero_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(NIL)), 1); |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(NIL, NIL)), 1); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(multiplication_one_args_test) { |
|
|
|
START_TEST(multiplication_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(LIST(number(69)))), 69); |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(LIST(number(69)), NIL)), 69); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(multiplication_many_args_test) { |
|
|
|
START_TEST(multiplication_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(LIST(number(69), number(420)))), 28980); |
|
|
|
ck_assert_double_eq(NUMBER(mul_fn(LIST(number(69), number(420)), NIL)), 28980); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(div_zero_args_test) { |
|
|
|
START_TEST(div_zero_args_test) { |
|
|
|
ck_assert_double_eq(div_fn(NIL), UNDEFINED); |
|
|
|
ck_assert_double_eq(div_fn(NIL, NIL), UNDEFINED); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(div_one_args_test) { |
|
|
|
START_TEST(div_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(div_fn(LIST(number(69)))), 1.0 / 69.0); |
|
|
|
ck_assert_double_eq(NUMBER(div_fn(LIST(number(69)), NIL)), 1.0 / 69.0); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(div_many_args_test) { |
|
|
|
START_TEST(div_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(div_fn(LIST(number(69), number(420)))), 69.0 / 420.0); |
|
|
|
ck_assert_double_eq(NUMBER(div_fn(LIST(number(69), number(420)), NIL)), 69.0 / 420.0); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(pow_test) { |
|
|
|
START_TEST(pow_test) { |
|
|
|
ck_assert_double_eq(NUMBER(pow_fn(LIST(number(69), number(3)))), pow(69.0, 3.0)); |
|
|
|
ck_assert_double_eq(NUMBER(pow_fn(LIST(number(69), number(3)), NIL)), pow(69.0, 3.0)); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(sqrt_test) { |
|
|
|
START_TEST(sqrt_test) { |
|
|
|
ck_assert_double_eq(NUMBER(sqrt_fn(LIST(number(69)))), sqrt(69.0)); |
|
|
|
ck_assert_double_eq(NUMBER(sqrt_fn(LIST(number(69)), NIL)), sqrt(69.0)); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logand_zero_args_test) { |
|
|
|
START_TEST(logand_zero_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(NIL)), -1l); |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(NIL, NIL)), -1l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logand_one_args_test) { |
|
|
|
START_TEST(logand_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(LIST(number(69)))), -1l & 69l); |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(LIST(number(69)), NIL)), -1l & 69l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logand_many_args_test) { |
|
|
|
START_TEST(logand_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(LIST(number(69), number(420)))), 69l & 420l); |
|
|
|
ck_assert_double_eq(NUMBER(logand_fn(LIST(number(69), number(420)), NIL)), 69l & 420l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logor_zero_args_test) { |
|
|
|
START_TEST(logor_zero_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(NIL)), 0l); |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(NIL, NIL)), 0l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logor_one_args_test) { |
|
|
|
START_TEST(logor_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(LIST(number(69)))), 0l | 69l); |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(LIST(number(69)), NIL)), 0l | 69l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logor_many_args_test) { |
|
|
|
START_TEST(logor_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(LIST(number(69), number(420)))), 69l | 420l); |
|
|
|
ck_assert_double_eq(NUMBER(logor_fn(LIST(number(69), number(420)), NIL)), 69l | 420l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logxor_zero_args_test) { |
|
|
|
START_TEST(logxor_zero_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(NIL)), 0l); |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(NIL, NIL)), 0l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logxor_one_args_test) { |
|
|
|
START_TEST(logxor_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(LIST(number(69)))), 0l ^ 69l); |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(LIST(number(69)), NIL)), 0l ^ 69l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(logxor_many_args_test) { |
|
|
|
START_TEST(logxor_many_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(LIST(number(69), number(420)))), 69l ^ 420l); |
|
|
|
ck_assert_double_eq(NUMBER(logxor_fn(LIST(number(69), number(420)), NIL)), 69l ^ 420l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(lognot_zero_args_test) { |
|
|
|
START_TEST(lognot_zero_args_test) { |
|
|
|
ck_assert_double_eq(lognot_fn(NIL), UNDEFINED); |
|
|
|
ck_assert_double_eq(lognot_fn(NIL, NIL), UNDEFINED); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(lognot_one_args_test) { |
|
|
|
START_TEST(lognot_one_args_test) { |
|
|
|
ck_assert_double_eq(NUMBER(lognot_fn(LIST(number(69)))), ~69l); |
|
|
|
ck_assert_double_eq(NUMBER(lognot_fn(LIST(number(69)), NIL)), ~69l); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
@ -179,8 +179,8 @@ START_TEST(or_test) { |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|
START_TEST(not_test) { |
|
|
|
START_TEST(not_test) { |
|
|
|
ck_assert_double_eq(not_fn(LIST(NIL)), T); |
|
|
|
ck_assert_double_eq(not_fn(LIST(NIL), NIL), T); |
|
|
|
ck_assert_uint_eq(not_fn(LIST(T)), NIL); |
|
|
|
ck_assert_uint_eq(not_fn(LIST(T), NIL), NIL); |
|
|
|
} |
|
|
|
} |
|
|
|
END_TEST |
|
|
|
END_TEST |
|
|
|
|
|
|
|
|
|
|
|