@@ -14,8 +14,8 @@ function ordered(U: nsf.Union): boolean {
1414 return true ;
1515}
1616
17- describe ( "union " , ( ) => {
18- it ( "union creation" , ( ) => {
17+ describe ( "Union " , ( ) => {
18+ it ( "Union creation" , ( ) => {
1919 // From a list of intervals
2020 assert . ok ( ordered ( nsf . union ( [ ] ) ) ) ;
2121 assert . ok ( ordered ( nsf . union ( [ nsf . interval ( - Infinity , Infinity ) ] ) ) ) ;
@@ -36,7 +36,7 @@ describe("union", () => {
3636 assert . ok ( ordered ( nsf . union ( [ a , b , nsf . interval ( 5 , 6 ) , nsf . interval ( - 1000 , - 500 ) ] ) ) ) ;
3737 } ) ;
3838
39- it ( "union contains" , ( ) => {
39+ it ( "Union. contains() " , ( ) => {
4040 const a = nsf . union ( [ nsf . interval ( 0 , 10 ) , nsf . interval ( 50 , 60 ) ] ) ;
4141 assert . ok ( ! nsf . EMPTY . contains ( 0 ) ) ;
4242 assert . ok ( a . contains ( 0 ) ) ;
@@ -50,7 +50,7 @@ describe("union", () => {
5050 assert . ok ( ! a . contains ( 15 ) ) ;
5151 } ) ;
5252
53- it ( "union subset" , ( ) => {
53+ it ( "Union. subset() " , ( ) => {
5454 const a = nsf . union ( [ nsf . interval ( 0 , 10 ) , nsf . interval ( 50 , 60 ) ] ) ;
5555 assert . ok ( a . subset ( nsf . single ( 0 , 100 ) ) ) ;
5656 assert . ok ( a . subset ( nsf . FULL ) ) ;
@@ -59,15 +59,15 @@ describe("union", () => {
5959 assert . ok ( nsf . EMPTY . subset ( nsf . FULL ) ) ;
6060 } ) ;
6161
62- it ( "union superset" , ( ) => {
62+ it ( "Union. superset() " , ( ) => {
6363 const a = nsf . union ( [ nsf . interval ( 0 , 10 ) , nsf . interval ( 50 , 60 ) ] ) ;
6464 assert . ok ( a . superset ( nsf . single ( 0 , 1 ) ) ) ;
6565 assert . ok ( a . superset ( nsf . EMPTY ) ) ;
6666 assert . ok ( a . superset ( nsf . union ( [ nsf . interval ( 2 , 3 ) , nsf . interval ( 5 , 6 ) ] ) ) ) ;
6767 assert . ok ( nsf . FULL . superset ( nsf . EMPTY ) ) ;
6868 } ) ;
6969
70- it ( "union isFinite" , ( ) => {
70+ it ( "union. isFinite() " , ( ) => {
7171 assert . ok ( nsf . EMPTY . isFinite ( ) ) ;
7272 assert . ok ( nsf . single ( 0 , 1 ) . isFinite ( ) ) ;
7373 assert . ok ( nsf . union ( [ nsf . single ( 0 , 1 ) , nsf . single ( 4 , 5 ) ] ) . isFinite ( ) ) ;
@@ -90,4 +90,20 @@ describe("union", () => {
9090
9191 assert . deepEqual ( nsf . FULL . width ( ) , Infinity ) ;
9292 } ) ;
93+
94+ it ( "Union.count()" , ( ) => {
95+ assert . deepEqual ( nsf . EMPTY . count ( ) , 0 ) ;
96+ assert . deepEqual ( nsf . single ( 0 , 0 ) . count ( ) , 1 ) ;
97+ assert . deepEqual ( nsf . FULL . count ( ) , 1 ) ;
98+ assert . deepEqual ( nsf . union ( [ nsf . single ( 0 , 0 ) , nsf . single ( 1 , 2 ) ] ) . count ( ) , 2 ) ;
99+ } ) ;
100+
101+ it ( "Union.isSingle()" , ( ) => {
102+ assert . deepEqual ( nsf . EMPTY . isSingle ( ) , false ) ;
103+ assert . deepEqual ( nsf . FULL . isSingle ( ) , true ) ;
104+ assert . deepEqual ( nsf . single ( 0 , 0 ) . isSingle ( ) , true ) ;
105+ assert . deepEqual ( nsf . single ( 0 , 1 ) . isSingle ( ) , true ) ;
106+ assert . deepEqual ( nsf . single ( - 1 , 1 ) . isSingle ( ) , true ) ;
107+ assert . deepEqual ( nsf . union ( [ nsf . single ( 0 , 1 ) , nsf . single ( 10 , 11 ) ] ) . isSingle ( ) , false ) ;
108+ } ) ;
93109} ) ;
0 commit comments