<commit_before># test suite for GerberParser class
Parser = require '../src/gerber-parser'

param = (p) -> { param: [ p ] }
block = (b) -> { block: b }

describe 'gerber command parser', ->
  p = null
  beforeEach -> p = new Parser

  it 'should ignore comments (start with G04)', ->
    initialFormat = { zero: p.format.zero, places: p.format.places }
    p.parseCommand(block 'G04 MOIN').should.eql {}
    p.parseCommand(block 'G04 this is a comment').should.eql {}
    p.parseCommand(block 'G04 D03').should.eql {}
    p.parseCommand(block 'G04 D02').should.eql {}
    p.parseCommand(block 'G04 G36').should.eql {}
    p.parseCommand(block 'G04 M02').should.eql {}
    p.format.should.eql initialFormat

  describe 'parsing the format block', ->
    it 'should handle it with good options', ->
      p.parseCommand(param 'FSLAX34Y34').should.eql { set: { notation: 'A' } }
      p.format.zero.should.eql 'L'
      p.format.places.should.eql [3,4]
      p.parseCommand(param 'FSTIX77Y77').should.eql { set: { notation: 'I' } }
      p.format.zero.should.eql 'T'
      p.format.places.should.eql [7,7]
    it 'should throw error for bad options', ->
      (-> p.parseCommand(param 'FSLPX34Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSFAX34Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX12Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAY34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX3.4Y3.4')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLA')).should.throw /invalid/
      (-> p.parseCommand(param 'FSpoop')).should.throw /invalid/

  describe 'parsing an aperture definition', ->
    describe 'with standard tools', ->
      it 'should handle standard circles', -><commit_msg>add test for issue #5<commit_after># test suite for GerberParser class
Parser = require '../src/gerber-parser'

param = (p) -> { param: [ p ] }
block = (b) -> { block: b }

describe 'gerber command parser', ->
  p = null
  beforeEach -> p = new Parser

  it 'should ignore comments (start with G04)', ->
    initialFormat = { zero: p.format.zero, places: p.format.places }
    p.parseCommand(block 'G04 MOIN').should.eql {}
    p.parseCommand(block 'G04 this is a comment').should.eql {}
    p.parseCommand(block 'G04 D03').should.eql {}
    p.parseCommand(block 'G04 D02').should.eql {}
    p.parseCommand(block 'G04 G36').should.eql {}
    p.parseCommand(block 'G04 M02').should.eql {}
    p.format.should.eql initialFormat

  describe 'parsing the format block', ->
    it 'should handle it with good options', ->
      p.parseCommand(param 'FSLAX34Y34').should.eql { set: { notation: 'A' } }
      p.format.zero.should.eql 'L'
      p.format.places.should.eql [3,4]
      p.parseCommand(param 'FSTIX77Y77').should.eql { set: { notation: 'I' } }
      p.format.zero.should.eql 'T'
      p.format.places.should.eql [7,7]
    it 'should throw error for bad options', ->
      (-> p.parseCommand(param 'FSLPX34Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSFAX34Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX12Y34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAY34')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLAX3.4Y3.4')).should.throw /invalid/
      (-> p.parseCommand(param 'FSLA')).should.throw /invalid/
      (-> p.parseCommand(param 'FSpoop')).should.throw /invalid/

  describe 'parsing an aperture definition', ->
    it 'should remove leading zeros from the tool code string', ->
      p.parseCommand(param 'ADD010C,1').should.eql {
        tool: { D10: { dia: 1 } }
      }
      p.parseCommand(param 'ADD0011C,1').should.eql {
        tool: { D11: { dia: 1 } }
      }
    describe 'with standard tools', ->
      it 'should handle standard circles', ->
{'fraction_non_alphanumeric': 0.1652262328418912, 'fraction_numerical': 0.0315200813421454, 'mean_word_length': 3.0112130479102954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529742', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1350, 'n_words': 300}