mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-29 15:30:04 +02:00
Added all_nonzero(). Added is_vector(all_nonzero=).
This commit is contained in:
@@ -122,6 +122,30 @@ module test_all_zero() {
|
||||
test_all_zero();
|
||||
|
||||
|
||||
module test_all_nonzero() {
|
||||
assert(!all_nonzero(0));
|
||||
assert(!all_nonzero([0,0,0]));
|
||||
assert(!all_nonzero([[0,0,0],[0,0]]));
|
||||
assert(!all_nonzero([EPSILON/2,EPSILON/2,EPSILON/2]));
|
||||
assert(all_nonzero(1e-3));
|
||||
assert(!all_nonzero([0,0,1e-3]));
|
||||
assert(!all_nonzero([EPSILON*10,0,0]));
|
||||
assert(!all_nonzero([0,EPSILON*10,0]));
|
||||
assert(!all_nonzero([0,0,EPSILON*10]));
|
||||
assert(all_nonzero([1e-3,1e-3,1e-3]));
|
||||
assert(all_nonzero([EPSILON*10,EPSILON*10,EPSILON*10]));
|
||||
assert(!all_nonzero(true));
|
||||
assert(!all_nonzero(false));
|
||||
assert(!all_nonzero(INF));
|
||||
assert(!all_nonzero(-INF));
|
||||
assert(!all_nonzero(NAN));
|
||||
assert(!all_nonzero("foo"));
|
||||
assert(!all_nonzero([]));
|
||||
assert(!all_nonzero([0:1:2]));
|
||||
}
|
||||
test_all_nonzero();
|
||||
|
||||
|
||||
module test_all_positive() {
|
||||
assert(!all_positive(-2));
|
||||
assert(!all_positive(0));
|
||||
|
@@ -14,6 +14,14 @@ module test_is_vector() {
|
||||
assert(is_vector([0,0,0],zero=false) == false);
|
||||
assert(is_vector([0,1,0],zero=true) == false);
|
||||
assert(is_vector([0,0,1],zero=false) == true);
|
||||
assert(is_vector([1,1,1],zero=false) == true);
|
||||
|
||||
assert(is_vector([0,0,0],all_nonzero=true) == false);
|
||||
assert(is_vector([0,1,0],all_nonzero=true) == false);
|
||||
assert(is_vector([0,0,1],all_nonzero=true) == false);
|
||||
assert(is_vector([1,1,1],all_nonzero=true) == true);
|
||||
assert(is_vector([-1,1,1],all_nonzero=true) == true);
|
||||
assert(is_vector([-1,-1,-1],all_nonzero=true) == true);
|
||||
}
|
||||
test_is_vector();
|
||||
|
||||
|
Reference in New Issue
Block a user