@@ -240,4 +240,72 @@ describe('G-code Interpreter', () => {
240240 } ) ;
241241 } ) ;
242242
243+ describe ( 'G-code: T2Laser' , ( ) => {
244+ class Runner extends Interpreter {
245+ calls = { } ;
246+
247+ constructor ( options ) {
248+ super ( options ) ;
249+ }
250+ M3 ( args ) {
251+ expect ( args ) . to . be . an ( 'object' ) ;
252+ this . calls . M3 = ( this . calls . M3 || 0 ) + 1 ;
253+ }
254+ M5 ( args ) {
255+ expect ( args ) . to . be . an ( 'object' ) ;
256+ this . calls . M5 = ( this . calls . M5 || 0 ) + 1 ;
257+ }
258+ M6 ( args ) {
259+ expect ( args ) . to . be . an ( 'object' ) ;
260+ expect ( args . T ) . to . equal ( 1 ) ;
261+ this . calls . M6 = ( this . calls . M6 || 0 ) + 1 ;
262+ }
263+ T ( args ) {
264+ expect ( args ) . to . be . an ( 'number' ) ;
265+ expect ( args ) . to . equal ( 2 ) ;
266+ this . calls . T = ( this . calls . T || 0 ) + 1 ;
267+ }
268+ F ( args ) {
269+ expect ( args ) . to . be . an ( 'number' ) ;
270+ this . calls . F = ( this . calls . F || 0 ) + 1 ;
271+ }
272+ G0 ( args ) {
273+ expect ( args ) . to . be . an ( 'object' ) ;
274+ this . calls . G0 = ( this . calls . G0 || 0 ) + 1 ;
275+ }
276+ G1 ( args ) {
277+ expect ( args ) . to . be . an ( 'object' ) ;
278+ this . calls . G1 = ( this . calls . G1 || 0 ) + 1 ;
279+ }
280+ }
281+
282+ it ( 'should call each function with the expected number of times.' , ( done ) => {
283+ const file = 'test/fixtures/t2laser.nc' ;
284+ const runner = new Runner ( ) ;
285+ runner . loadFromFileSync ( file ) ;
286+ expect ( runner . calls . M3 ) . to . equal ( 31 ) ;
287+ expect ( runner . calls . M5 ) . to . equal ( 1 ) ;
288+ expect ( runner . calls . M6 ) . to . equal ( 1 ) ;
289+ expect ( runner . calls . T ) . to . equal ( 1 ) ;
290+ expect ( runner . calls . F ) . to . equal ( 1 ) ;
291+ expect ( runner . calls . G0 ) . to . equal ( 2 ) ;
292+ expect ( runner . calls . G1 ) . to . equal ( 31 ) ;
293+ done ( ) ;
294+ } ) ;
295+
296+ it ( 'should call each function with the expected number of times.' , ( done ) => {
297+ const file = 'test/fixtures/t2laser.nc' ;
298+ const string = fs . readFileSync ( file , 'utf8' ) ;
299+ const runner = new Runner ( ) ;
300+ runner . loadFromStringSync ( string ) ;
301+ expect ( runner . calls . M3 ) . to . equal ( 31 ) ;
302+ expect ( runner . calls . M5 ) . to . equal ( 1 ) ;
303+ expect ( runner . calls . M6 ) . to . equal ( 1 ) ;
304+ expect ( runner . calls . T ) . to . equal ( 1 ) ;
305+ expect ( runner . calls . F ) . to . equal ( 1 ) ;
306+ expect ( runner . calls . G0 ) . to . equal ( 2 ) ;
307+ expect ( runner . calls . G1 ) . to . equal ( 31 ) ;
308+ done ( ) ;
309+ } ) ;
310+ } ) ;
243311} ) ;
0 commit comments