File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ export function toInt(term) {
147147 } else if ( config . numEncoding === "None" )
148148 return term ;
149149 else
150- return numEncoding . toInt ( term ) ; // Custom encoding
150+ return config . numEncoding . toInt ( term ) ; // Custom encoding
151151 } catch ( e ) {
152152 if ( config . verbosity >= "Concise" ) console . error ( `toInt: ${ term } is not a number in numEncoding ${ numEncoding } ` ) ;
153153 throw e ;
Original file line number Diff line number Diff line change 11import { readFileSync } from "fs" ;
22
3- export { assert , config } from "chai" ;
4- export * as LC from "@codewars/lambda-calculus" ;
3+ import { assert , config } from "chai" ;
4+ import * as LC from "../src/lambda-calculus.js" ;
5+
6+ export { assert , config , LC } ;
57
68const read = ( path ) => readFileSync ( new URL ( path , import . meta. url ) , { encoding : "utf8" } ) ;
79
@@ -13,3 +15,16 @@ export const getPreloaded = () => read("./preloaded.lc");
1315
1416/** Return the contents of the preloaded file and the solution file combined */
1517export const getSolutionWithPreloaded = ( ) => getPreloaded ( ) + "\n_ = ()\n" + getSolution ( ) ;
18+
19+
20+ /** Custom assertions */
21+
22+ function numEql ( got , exp , msg ) {
23+ if ( got ?. term && got ?. env ) got = LC . toInt ( got ) ;
24+ if ( exp ?. term && exp ?. env ) exp = LC . toInt ( exp ) ;
25+ return this . equal ( got , exp , msg ) ;
26+ }
27+
28+ Object . assign ( assert , {
29+ numEql
30+ } ) ;
You can’t perform that action at this time.
0 commit comments