1+ import { expect } from "../../test/chai-workaround" ;
2+
13import { Alg } from "./Alg" ;
24import { setAlgDebug } from "./debug" ;
35import { parseAlg } from "./parseAlg" ;
4- import "./test/alg-comparison" ;
56
67describe ( "amount" , ( ) => {
78 it ( "handles 0 amounts" , ( ) => {
8- expect ( parseAlg ( "R0" ) . toString ( ) ) . toEqual ( "R0" ) ;
9+ expect ( parseAlg ( "R0" ) . toString ( ) ) . to . equal ( "R0" ) ;
910 // We currently allow `R0'` because some programs might need to go out of their
1011 // way to avoid producing it in an edge cases. It's interpreted the same as
1112 // `R0`.
12- expect ( parseAlg ( "R0'" ) . toString ( ) ) . toEqual ( "R0" ) ;
13- expect ( ( ) => parseAlg ( "R01" ) ) . toThrow (
13+ expect ( parseAlg ( "R0'" ) . toString ( ) ) . to . equal ( "R0" ) ;
14+ expect ( ( ) => parseAlg ( "R01" ) ) . to . throw (
1415 "Error at char index 1: An amount can only start with 0 if it's exactly the digit 0." ,
1516 ) ;
16- expect ( ( ) => parseAlg ( "R00" ) ) . toThrow (
17+ expect ( ( ) => parseAlg ( "R00" ) ) . to . throw (
1718 "Error at char index 1: An amount can only start with 0 if it's exactly the digit 0." ,
1819 ) ;
1920 } ) ;
@@ -25,34 +26,34 @@ describe("Clock", () => {
2526 parseAlg (
2627 " UR4+ DR4+ DL1+ UL3- U1+ R2- D5+ L6+ ALL4- y2 U3- R5- D4+ L6+ ALL5+ UL" ,
2728 ) . toString ( ) ,
28- ) . toEqual (
29+ ) . to . equal (
2930 "UR4+ DR4+ DL1+ UL3- U1+ R2- D5+ L6+ ALL4- y2 U3- R5- D4+ L6+ ALL5+ UL" ,
3031 ) ;
31- expect ( parseAlg ( "UR_PLUS_4 D_PLUS_3' U1+" ) . toString ( ) ) . toEqual (
32+ expect ( parseAlg ( "UR_PLUS_4 D_PLUS_3' U1+" ) . toString ( ) ) . to . equal (
3233 "UR4+ D3- U1+" ,
3334 ) ;
34- expect ( ( ) => parseAlg ( "UR+" ) . toString ( ) ) . toThrow (
35+ expect ( ( ) => parseAlg ( "UR+" ) . toString ( ) ) . to . throw (
3536 "Clock dial moves must have an amount written as a natural number followed by + or -." ,
3637 ) ;
37- expect ( ( ) => parseAlg ( "UR+2" ) . toString ( ) ) . toThrow (
38+ expect ( ( ) => parseAlg ( "UR+2" ) . toString ( ) ) . to . throw (
3839 "Clock dial moves must have an amount written as a natural number followed by + or -." ,
3940 ) ;
40- expect ( ( ) => parseAlg ( "UR1+2" ) . toString ( ) ) . toThrow (
41+ expect ( ( ) => parseAlg ( "UR1+2" ) . toString ( ) ) . to . throw (
4142 "Unexpected character at index 4. Are you missing a space?" ,
4243 ) ; // TODO: Better message
4344 } ) ;
4445} ) ;
4546
4647describe ( "Megaminx" , ( ) => {
4748 it ( "parses notation" , ( ) => {
48- expect ( parseAlg ( " R++ D-- U' \n R++ D++ U" ) . toString ( ) ) . toEqual (
49+ expect ( parseAlg ( " R++ D-- U' \n R++ D++ U" ) . toString ( ) ) . to . equal (
4950 "R++ D-- U'\nR++ D++ U" ,
5051 ) ;
51- expect ( parseAlg ( "R_PLUSPLUS_ D_PLUSPLUS_'" ) . toString ( ) ) . toEqual ( "R++ D--" ) ;
52- expect ( ( ) => parseAlg ( "R1++" ) . toString ( ) ) . toThrow (
52+ expect ( parseAlg ( "R_PLUSPLUS_ D_PLUSPLUS_'" ) . toString ( ) ) . to . equal ( "R++ D--" ) ;
53+ expect ( ( ) => parseAlg ( "R1++" ) . toString ( ) ) . to . throw (
5354 "Pochmann ++ or -- moves cannot have an amount written as a number." ,
5455 ) ;
55- expect ( ( ) => parseAlg ( "R2++" ) . toString ( ) ) . toThrow (
56+ expect ( ( ) => parseAlg ( "R2++" ) . toString ( ) ) . to . throw (
5657 "Pochmann ++ or -- moves cannot have an amount other than 1." ,
5758 ) ;
5859 } ) ;
@@ -64,26 +65,27 @@ describe("Square-1", () => {
6465 parseAlg (
6566 "/ (-3,0) / (0, 3)/ (0,-3)/ (0,3) / (2,0) / (0,2)/ (-2,0) / (4,0) / (0,-2) / (0, 2) / (-1,4) / (0, -3) / (0, 3)" ,
6667 ) . toString ( ) ,
67- ) . toEqual (
68+ ) . to . equal (
6869 "/ (-3, 0) / (0, 3) / (0, -3) / (0, 3) / (2, 0) / (0, 2) / (-2, 0) / (4, 0) / (0, -2) / (0, 2) / (-1, 4) / (0, -3) / (0, 3)" ,
6970 ) ;
70- expect ( parseAlg ( "_SLASH_ (U_SQ_3' D_SQ_0) / (0, 3)" ) . toString ( ) ) . toEqual (
71+ expect ( parseAlg ( "_SLASH_ (U_SQ_3' D_SQ_0) / (0, 3)" ) . toString ( ) ) . to . equal (
7172 "/ (-3, 0) / (0, 3)" ,
7273 ) ;
73- expect ( ( ) => parseAlg ( "(3, 4) /(1, 2)" ) . toString ( ) ) . toThrow (
74+ expect ( ( ) => parseAlg ( "(3, 4) /(1, 2)" ) . toString ( ) ) . to . throw (
7475 "Unexpected character at index 8. Are you missing a space?" ,
7576 ) ;
7677 } ) ;
7778} ) ;
7879
7980describe ( "NISS" , ( ) => {
8081 it ( "does not allow carat NISS notation by default" , ( ) => {
81- expect ( ( ) => parseAlg ( "R ^(U) D" ) . toString ( ) ) . toThrow (
82+ expect ( ( ) => parseAlg ( "R ^(U) D" ) . toString ( ) ) . to . throw (
8283 "Alg contained a carat but carat NISS notation is not enabled." ,
8384 ) ;
8485 } ) ;
8586 it ( "parses carat NISS notation" , ( ) => {
8687 setAlgDebug ( { caratNISSNotationEnabled : true } ) ;
87- expect ( parseAlg ( "R ^(U L) D" ) ) . toBeIdentical ( new Alg ( "R . D (U L)'" ) ) ;
88+ expect ( parseAlg ( "R ^(U L) D" ) . isIdentical ( new Alg ( "R . D (U L)'" ) ) ) . to . be
89+ . true ;
8890 } ) ;
8991} ) ;
0 commit comments