diff --git a/src/anchor.js b/src/anchor.js index e00c612..169ff3c 100644 --- a/src/anchor.js +++ b/src/anchor.js @@ -17,8 +17,11 @@ const aggregator_common = ['parts', 'method'] const aggregators = { average: (config, name, parts) => { a.unexpected(config, name, aggregator_common) - let x = 0, y = 0, r = 0 const len = parts.length + if (len == 0) { + return new Point() + } + let x = 0, y = 0, r = 0 for (const part of parts) { x += part.x y += part.y diff --git a/test/cases/operations.yaml b/test/cases/operations.yaml new file mode 100644 index 0000000..47984f1 --- /dev/null +++ b/test/cases/operations.yaml @@ -0,0 +1,36 @@ +points.zones.matrix: {} +outlines: + _square: + - what: rectangle + where: true + size: [8, 8] + _circle: + - what: circle + where: true + radius: 3 +cases: + _cube: + - name: _square + extrude: 8 + _cylinder_one: + - name: _circle + extrude: 8 + _subtract: + target: + name: _cube + what: case + tool: + name: _cylinder_one + what: case + operation: subtract + _cylinder_two: + - name: _circle + extrude: 8 + shift: [0,4,4] + rotate: [90,0,0] + _flat_square: + - "_square" + combination: + - "_subtract" + - "~_cylinder_two" + - "+_flat_square" diff --git a/test/cases/operations___cases_combination_jscad.jscad b/test/cases/operations___cases_combination_jscad.jscad new file mode 100644 index 0000000..2606dde --- /dev/null +++ b/test/cases/operations___cases_combination_jscad.jscad @@ -0,0 +1,205 @@ +function _square_outline_fn(){ + return new CSG.Path2D([[-4,-4],[4,-4]]).appendPoint([4,4]).appendPoint([-4,4]).appendPoint([-4,-4]).close().innerToCAG() +.extrude({ offset: [0, 0, 8] }); +} + + +function _circle_outline_fn(){ + return CAG.circle({"center":[0,0],"radius":3}) +.extrude({ offset: [0, 0, 8] }); +} + + + + + function _subtract_case_fn() { + + + // creating part target of case _subtract + let _subtract__part_target = _cube_case_fn(); + + // make sure that rotations are relative + let _subtract__part_target_bounds = _subtract__part_target.getBounds(); + let _subtract__part_target_x = _subtract__part_target_bounds[0].x + (_subtract__part_target_bounds[1].x - _subtract__part_target_bounds[0].x) / 2 + let _subtract__part_target_y = _subtract__part_target_bounds[0].y + (_subtract__part_target_bounds[1].y - _subtract__part_target_bounds[0].y) / 2 + _subtract__part_target = translate([-_subtract__part_target_x, -_subtract__part_target_y, 0], _subtract__part_target); + _subtract__part_target = rotate([0,0,0], _subtract__part_target); + _subtract__part_target = translate([_subtract__part_target_x, _subtract__part_target_y, 0], _subtract__part_target); + + _subtract__part_target = translate([0,0,0], _subtract__part_target); + let result = _subtract__part_target; + + + + // creating part tool of case _subtract + let _subtract__part_tool = _cylinder_one_case_fn(); + + // make sure that rotations are relative + let _subtract__part_tool_bounds = _subtract__part_tool.getBounds(); + let _subtract__part_tool_x = _subtract__part_tool_bounds[0].x + (_subtract__part_tool_bounds[1].x - _subtract__part_tool_bounds[0].x) / 2 + let _subtract__part_tool_y = _subtract__part_tool_bounds[0].y + (_subtract__part_tool_bounds[1].y - _subtract__part_tool_bounds[0].y) / 2 + _subtract__part_tool = translate([-_subtract__part_tool_x, -_subtract__part_tool_y, 0], _subtract__part_tool); + _subtract__part_tool = rotate([0,0,0], _subtract__part_tool); + _subtract__part_tool = translate([_subtract__part_tool_x, _subtract__part_tool_y, 0], _subtract__part_tool); + + _subtract__part_tool = translate([0,0,0], _subtract__part_tool); + result = result.subtract(_subtract__part_tool); + + + return result; + } + + + + function _cube_case_fn() { + + + // creating part 0 of case _cube + let _cube__part_0 = _square_outline_fn(); + + // make sure that rotations are relative + let _cube__part_0_bounds = _cube__part_0.getBounds(); + let _cube__part_0_x = _cube__part_0_bounds[0].x + (_cube__part_0_bounds[1].x - _cube__part_0_bounds[0].x) / 2 + let _cube__part_0_y = _cube__part_0_bounds[0].y + (_cube__part_0_bounds[1].y - _cube__part_0_bounds[0].y) / 2 + _cube__part_0 = translate([-_cube__part_0_x, -_cube__part_0_y, 0], _cube__part_0); + _cube__part_0 = rotate([0,0,0], _cube__part_0); + _cube__part_0 = translate([_cube__part_0_x, _cube__part_0_y, 0], _cube__part_0); + + _cube__part_0 = translate([0,0,0], _cube__part_0); + let result = _cube__part_0; + + + return result; + } + + + + function _cylinder_one_case_fn() { + + + // creating part 0 of case _cylinder_one + let _cylinder_one__part_0 = _circle_outline_fn(); + + // make sure that rotations are relative + let _cylinder_one__part_0_bounds = _cylinder_one__part_0.getBounds(); + let _cylinder_one__part_0_x = _cylinder_one__part_0_bounds[0].x + (_cylinder_one__part_0_bounds[1].x - _cylinder_one__part_0_bounds[0].x) / 2 + let _cylinder_one__part_0_y = _cylinder_one__part_0_bounds[0].y + (_cylinder_one__part_0_bounds[1].y - _cylinder_one__part_0_bounds[0].y) / 2 + _cylinder_one__part_0 = translate([-_cylinder_one__part_0_x, -_cylinder_one__part_0_y, 0], _cylinder_one__part_0); + _cylinder_one__part_0 = rotate([0,0,0], _cylinder_one__part_0); + _cylinder_one__part_0 = translate([_cylinder_one__part_0_x, _cylinder_one__part_0_y, 0], _cylinder_one__part_0); + + _cylinder_one__part_0 = translate([0,0,0], _cylinder_one__part_0); + let result = _cylinder_one__part_0; + + + return result; + } + + + + function _cylinder_two_case_fn() { + + + // creating part 0 of case _cylinder_two + let _cylinder_two__part_0 = _circle_outline_fn(); + + // make sure that rotations are relative + let _cylinder_two__part_0_bounds = _cylinder_two__part_0.getBounds(); + let _cylinder_two__part_0_x = _cylinder_two__part_0_bounds[0].x + (_cylinder_two__part_0_bounds[1].x - _cylinder_two__part_0_bounds[0].x) / 2 + let _cylinder_two__part_0_y = _cylinder_two__part_0_bounds[0].y + (_cylinder_two__part_0_bounds[1].y - _cylinder_two__part_0_bounds[0].y) / 2 + _cylinder_two__part_0 = translate([-_cylinder_two__part_0_x, -_cylinder_two__part_0_y, 0], _cylinder_two__part_0); + _cylinder_two__part_0 = rotate([90,0,0], _cylinder_two__part_0); + _cylinder_two__part_0 = translate([_cylinder_two__part_0_x, _cylinder_two__part_0_y, 0], _cylinder_two__part_0); + + _cylinder_two__part_0 = translate([0,4,4], _cylinder_two__part_0); + let result = _cylinder_two__part_0; + + + return result; + } + + + + function _flat_square_case_fn() { + + + // creating part 0 of case _flat_square + let _flat_square__part_0 = _square_outline_fn(); + + // make sure that rotations are relative + let _flat_square__part_0_bounds = _flat_square__part_0.getBounds(); + let _flat_square__part_0_x = _flat_square__part_0_bounds[0].x + (_flat_square__part_0_bounds[1].x - _flat_square__part_0_bounds[0].x) / 2 + let _flat_square__part_0_y = _flat_square__part_0_bounds[0].y + (_flat_square__part_0_bounds[1].y - _flat_square__part_0_bounds[0].y) / 2 + _flat_square__part_0 = translate([-_flat_square__part_0_x, -_flat_square__part_0_y, 0], _flat_square__part_0); + _flat_square__part_0 = rotate([0,0,0], _flat_square__part_0); + _flat_square__part_0 = translate([_flat_square__part_0_x, _flat_square__part_0_y, 0], _flat_square__part_0); + + _flat_square__part_0 = translate([0,0,0], _flat_square__part_0); + let result = _flat_square__part_0; + + + return result; + } + + + + function combination_case_fn() { + + + // creating part 0 of case combination + let combination__part_0 = _subtract_case_fn(); + + // make sure that rotations are relative + let combination__part_0_bounds = combination__part_0.getBounds(); + let combination__part_0_x = combination__part_0_bounds[0].x + (combination__part_0_bounds[1].x - combination__part_0_bounds[0].x) / 2 + let combination__part_0_y = combination__part_0_bounds[0].y + (combination__part_0_bounds[1].y - combination__part_0_bounds[0].y) / 2 + combination__part_0 = translate([-combination__part_0_x, -combination__part_0_y, 0], combination__part_0); + combination__part_0 = rotate([0,0,0], combination__part_0); + combination__part_0 = translate([combination__part_0_x, combination__part_0_y, 0], combination__part_0); + + combination__part_0 = translate([0,0,0], combination__part_0); + let result = combination__part_0; + + + + // creating part 1 of case combination + let combination__part_1 = _cylinder_two_case_fn(); + + // make sure that rotations are relative + let combination__part_1_bounds = combination__part_1.getBounds(); + let combination__part_1_x = combination__part_1_bounds[0].x + (combination__part_1_bounds[1].x - combination__part_1_bounds[0].x) / 2 + let combination__part_1_y = combination__part_1_bounds[0].y + (combination__part_1_bounds[1].y - combination__part_1_bounds[0].y) / 2 + combination__part_1 = translate([-combination__part_1_x, -combination__part_1_y, 0], combination__part_1); + combination__part_1 = rotate([0,0,0], combination__part_1); + combination__part_1 = translate([combination__part_1_x, combination__part_1_y, 0], combination__part_1); + + combination__part_1 = translate([0,0,0], combination__part_1); + result = result.intersect(combination__part_1); + + + + // creating part 2 of case combination + let combination__part_2 = _flat_square_case_fn(); + + // make sure that rotations are relative + let combination__part_2_bounds = combination__part_2.getBounds(); + let combination__part_2_x = combination__part_2_bounds[0].x + (combination__part_2_bounds[1].x - combination__part_2_bounds[0].x) / 2 + let combination__part_2_y = combination__part_2_bounds[0].y + (combination__part_2_bounds[1].y - combination__part_2_bounds[0].y) / 2 + combination__part_2 = translate([-combination__part_2_x, -combination__part_2_y, 0], combination__part_2); + combination__part_2 = rotate([0,0,0], combination__part_2); + combination__part_2 = translate([combination__part_2_x, combination__part_2_y, 0], combination__part_2); + + combination__part_2 = translate([0,0,0], combination__part_2); + result = result.union(combination__part_2); + + + return result; + } + + + + function main() { + return combination_case_fn(); + } + + \ No newline at end of file diff --git a/test/fixtures/minimal_kle.json b/test/fixtures/minimal_kle.json new file mode 100644 index 0000000..0e60b85 --- /dev/null +++ b/test/fixtures/minimal_kle.json @@ -0,0 +1,15 @@ +[ + [ + "0_0", + "0_1" + ], + [ + "1_0", + "1_1" + ], + [ + "", + "" + ] +] + diff --git a/test/footprints/choc.yaml b/test/footprints/choc.yaml index 2c3e39e..016eeae 100644 --- a/test/footprints/choc.yaml +++ b/test/footprints/choc.yaml @@ -38,4 +38,14 @@ pcbs.pcb.footprints: to: to reverse: true hotswap: true - adjust.shift: [200, 0] \ No newline at end of file + adjust.shift: [200, 0] + + # all of keycaps, reverse and hotswap + - what: choc + params: + from: from + to: to + keycaps: true + reverse: true + hotswap: true + adjust.shift: [250, 0] diff --git a/test/footprints/choc___pcbs_pcb.kicad_pcb b/test/footprints/choc___pcbs_pcb.kicad_pcb index 3fabc5e..43736fd 100644 --- a/test/footprints/choc___pcbs_pcb.kicad_pcb +++ b/test/footprints/choc___pcbs_pcb.kicad_pcb @@ -284,6 +284,58 @@ + (pad "" np_thru_hole circle (at 5 -3.75) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at 0 -5.95) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + + + (pad 1 smd rect (at -3.275 -5.95 0) (size 2.6 2.6) (layers B.Cu B.Paste B.Mask) (net 1 "from")) + (pad 2 smd rect (at 8.275 -3.75 0) (size 2.6 2.6) (layers B.Cu B.Paste B.Mask) (net 2 "to")) + + + + (pad "" np_thru_hole circle (at -5 -3.75) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at 0 -5.95) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + + + (pad 1 smd rect (at 3.275 -5.95 0) (size 2.6 2.6) (layers F.Cu F.Paste F.Mask) (net 1 "from")) + (pad 2 smd rect (at -8.275 -3.75 0) (size 2.6 2.6) (layers F.Cu F.Paste F.Mask) (net 2 "to")) + ) + + + + (module PG1350 (layer F.Cu) (tedit 5DD50112) + (at 250 0 0) + + + (fp_text reference "S6" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + + + (fp_line (start -7 -6) (end -7 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7 7) (end -6 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -6 -7) (end -7 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7 7) (end -7 6) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 6) (end 7 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 -7) (end 6 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 6 7) (end 7 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 -7) (end 7 -6) (layer Dwgs.User) (width 0.15)) + + + (pad "" np_thru_hole circle (at 0 0) (size 3.429 3.429) (drill 3.429) (layers *.Cu *.Mask)) + + + (pad "" np_thru_hole circle (at 5.5 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at -5.5 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu *.Mask)) + + + + (fp_line (start -9 -8.5) (end 9 -8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9 -8.5) (end 9 8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9 8.5) (end -9 8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start -9 8.5) (end -9 -8.5) (layer Dwgs.User) (width 0.15)) + + + (pad "" np_thru_hole circle (at 5 -3.75) (size 3 3) (drill 3) (layers *.Cu *.Mask)) (pad "" np_thru_hole circle (at 0 -5.95) (size 3 3) (drill 3) (layers *.Cu *.Mask)) diff --git a/test/footprints/chocmini.yaml b/test/footprints/chocmini.yaml index 2cadb43..5312a0d 100644 --- a/test/footprints/chocmini.yaml +++ b/test/footprints/chocmini.yaml @@ -22,3 +22,12 @@ pcbs.pcb.footprints: to: to reverse: true adjust.shift: [100, 0] + + # reverse with keycap visualization + - what: chocmini + params: + from: from + to: to + keycaps: true + reverse: true + adjust.shift: [150, 0] diff --git a/test/footprints/chocmini___pcbs_pcb.kicad_pcb b/test/footprints/chocmini___pcbs_pcb.kicad_pcb index 650ceb0..784556a 100644 --- a/test/footprints/chocmini___pcbs_pcb.kicad_pcb +++ b/test/footprints/chocmini___pcbs_pcb.kicad_pcb @@ -267,6 +267,67 @@ ) + + + (module lib:Kailh_PG1232 (layer F.Cu) (tedit 5E1ADAC2) + (at 150 0 0) + + + (fp_text reference "S4" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value Kailh_PG1232 (at 0 -7.3) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15)))) + + + (fp_line (start -7.25 -6.75) (end -6.25 -6.75) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7.25 -6.75) (end -7.25 -5.75) (layer Dwgs.User) (width 0.15)) + + (fp_line (start -7.25 6.75) (end -6.25 6.75) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7.25 6.75) (end -7.25 5.75) (layer Dwgs.User) (width 0.15)) + + (fp_line (start 7.25 -6.75) (end 6.25 -6.75) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7.25 -6.75) (end 7.25 -5.75) (layer Dwgs.User) (width 0.15)) + + (fp_line (start 7.25 6.75) (end 6.25 6.75) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7.25 6.75) (end 7.25 5.75) (layer Dwgs.User) (width 0.15)) + + + (fp_line (start 2.8 -5.35) (end -2.8 -5.35) (layer Dwgs.User) (width 0.15)) + (fp_line (start -2.8 -3.2) (end 2.8 -3.2) (layer Dwgs.User) (width 0.15)) + (fp_line (start 2.8 -3.2) (end 2.8 -5.35) (layer Dwgs.User) (width 0.15)) + (fp_line (start -2.8 -3.2) (end -2.8 -5.35) (layer Dwgs.User) (width 0.15)) + + + (fp_line (start 2.25 2.6) (end 5.8 2.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start -2.25 2.6) (end -5.8 2.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start 2.25 3.6) (end 2.25 2.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start -2.25 3.6) (end 2.25 3.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start -2.25 2.6) (end -2.25 3.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start -5.8 2.6) (end -5.8 -2.95) (layer Edge.Cuts) (width 0.12)) + (fp_line (start 5.8 -2.95) (end 5.8 2.6) (layer Edge.Cuts) (width 0.12)) + (fp_line (start -5.8 -2.95) (end 5.8 -2.95) (layer Edge.Cuts) (width 0.12)) + + + (pad 3 thru_hole circle (at 5.3 -4.75) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (clearance 0.2)) + (pad 4 thru_hole circle (at -5.3 -4.75) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (clearance 0.2)) + + + + (fp_line (start -9 -8.5) (end 9 -8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9 -8.5) (end 9 8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9 8.5) (end -9 8.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start -9 8.5) (end -9 -8.5) (layer Dwgs.User) (width 0.15)) + + + + (pad 1 thru_hole circle (at -4.58 5.1) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (net 1 "from") (clearance 0.2)) + (pad 2 thru_hole circle (at 2 5.4) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (net 2 "to") (clearance 0.2)) + + + + (pad 1 thru_hole circle (at 4.58 5.1) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (net 1 "from") (clearance 0.2)) + (pad 2 thru_hole circle (at -2 5.4) (size 1.6 1.6) (drill 1.1) (layers *.Cu *.Mask) (net 2 "to") (clearance 0.2)) + ) + + ) diff --git a/test/footprints/mx.yaml b/test/footprints/mx.yaml index ee4a5dc..d1f200b 100644 --- a/test/footprints/mx.yaml +++ b/test/footprints/mx.yaml @@ -38,4 +38,14 @@ pcbs.pcb.footprints: to: to reverse: true hotswap: true - adjust.shift: [200, 0] \ No newline at end of file + adjust.shift: [200, 0] + + # all of keycaps, reverse and hotswap + - what: mx + params: + from: from + to: to + keycaps: true + reverse: true + hotswap: true + adjust.shift: [250, 0] diff --git a/test/footprints/mx___pcbs_pcb.kicad_pcb b/test/footprints/mx___pcbs_pcb.kicad_pcb index dbb3d65..01d7823 100644 --- a/test/footprints/mx___pcbs_pcb.kicad_pcb +++ b/test/footprints/mx___pcbs_pcb.kicad_pcb @@ -284,6 +284,58 @@ + (pad "" np_thru_hole circle (at 2.54 -5.08) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at -3.81 -2.54) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + + + (pad 1 smd rect (at -7.085 -2.54 0) (size 2.55 2.5) (layers B.Cu B.Paste B.Mask) (net 1 "from")) + (pad 2 smd rect (at 5.842 -5.08 0) (size 2.55 2.5) (layers B.Cu B.Paste B.Mask) (net 2 "to")) + + + + (pad "" np_thru_hole circle (at -2.54 -5.08) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at 3.81 -2.54) (size 3 3) (drill 3) (layers *.Cu *.Mask)) + + + (pad 1 smd rect (at 7.085 -2.54 0) (size 2.55 2.5) (layers F.Cu F.Paste F.Mask) (net 1 "from")) + (pad 2 smd rect (at -5.842 -5.08 0) (size 2.55 2.5) (layers F.Cu F.Paste F.Mask) (net 2 "to")) + ) + + + + (module MX (layer F.Cu) (tedit 5DD4F656) + (at 250 0 0) + + + (fp_text reference "S6" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + + + (fp_line (start -7 -6) (end -7 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7 7) (end -6 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -6 -7) (end -7 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start -7 7) (end -7 6) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 6) (end 7 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 -7) (end 6 -7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 6 7) (end 7 7) (layer Dwgs.User) (width 0.15)) + (fp_line (start 7 -7) (end 7 -6) (layer Dwgs.User) (width 0.15)) + + + (pad "" np_thru_hole circle (at 0 0) (size 3.9878 3.9878) (drill 3.9878) (layers *.Cu *.Mask)) + + + (pad "" np_thru_hole circle (at 5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at -5.08 0) (size 1.7018 1.7018) (drill 1.7018) (layers *.Cu *.Mask)) + + + + (fp_line (start -9.5 -9.5) (end 9.5 -9.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9.5 -9.5) (end 9.5 9.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start 9.5 9.5) (end -9.5 9.5) (layer Dwgs.User) (width 0.15)) + (fp_line (start -9.5 9.5) (end -9.5 -9.5) (layer Dwgs.User) (width 0.15)) + + + (pad "" np_thru_hole circle (at 2.54 -5.08) (size 3 3) (drill 3) (layers *.Cu *.Mask)) (pad "" np_thru_hole circle (at -3.81 -2.54) (size 3 3) (drill 3) (layers *.Cu *.Mask)) diff --git a/test/footprints/pad.yaml b/test/footprints/pad.yaml index 3d05355..43ed2d9 100644 --- a/test/footprints/pad.yaml +++ b/test/footprints/pad.yaml @@ -25,3 +25,17 @@ pcbs.pcb.footprints: align: down mirrored: true adjust.shift: [50, 50] + + - what: pad + params: + net: net + align: right + mirrored: true + adjust.shift: [100, 0] + + - what: pad + params: + net: net + align: left + mirrored: true + adjust.shift: [100, 50] diff --git a/test/footprints/pad___pcbs_pcb.kicad_pcb b/test/footprints/pad___pcbs_pcb.kicad_pcb index d34827d..997b2f6 100644 --- a/test/footprints/pad___pcbs_pcb.kicad_pcb +++ b/test/footprints/pad___pcbs_pcb.kicad_pcb @@ -181,6 +181,44 @@ ) + + + (module SMDPad (layer F.Cu) (tedit 5B24D78E) + + (at 100 0 0) + + + (fp_text reference "PAD5" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + + + (pad 1 smd rect (at 0 0 0) (size 1 1) (layers F.Cu F.Paste F.Mask) (net 1 "net")) + + (pad 1 smd rect (at 0 0 0) (size 1 1) (layers B.Cu B.Paste B.Mask) (net 1 "net")) + + + ) + + + + + (module SMDPad (layer F.Cu) (tedit 5B24D78E) + + (at 100 -50 0) + + + (fp_text reference "PAD6" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + + + (pad 1 smd rect (at 0 0 0) (size 1 1) (layers F.Cu F.Paste F.Mask) (net 1 "net")) + + (pad 1 smd rect (at 0 0 0) (size 1 1) (layers B.Cu B.Paste B.Mask) (net 1 "net")) + + + ) + + ) diff --git a/test/footprints/rest.yaml b/test/footprints/rest.yaml index 769682a..7e24468 100644 --- a/test/footprints/rest.yaml +++ b/test/footprints/rest.yaml @@ -64,4 +64,22 @@ pcbs.pcb.footprints: - what: via params: net: net - adjust.shift: [0, 150] \ No newline at end of file + adjust.shift: [0, 150] + + - what: scrollwheel + params: + from: from + to: to + A: A + B: B + C: C + D: D + reverse: true + adjust.shift: [50, 150] + + - what: slider + params: + from: from + to: to + side: B + adjust.shift: [100, 150] diff --git a/test/footprints/rest___pcbs_pcb.kicad_pcb b/test/footprints/rest___pcbs_pcb.kicad_pcb index db1fbf7..506f4fd 100644 --- a/test/footprints/rest___pcbs_pcb.kicad_pcb +++ b/test/footprints/rest___pcbs_pcb.kicad_pcb @@ -424,6 +424,104 @@ (pad 1 thru_hole circle (at 0 0) (size 0.6 0.6) (drill 0.3) (layers *.Cu) (zone_connect 2) (net 15 "net")) ) + + + (module RollerEncoder_Panasonic_EVQWGD001 (layer F.Cu) (tedit 6040A10C) + (at 50 -150 0) + (fp_text reference REF** (at 0 0 0) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15)))) + (fp_text value RollerEncoder_Panasonic_EVQWGD001 (at -0.1 9 0) (layer F.Fab) (effects (font (size 1 1) (thickness 0.15)))) + + + (fp_line (start -8.4 -6.4) (end 8.4 -6.4) (layer Dwgs.User) (width 0.12)) + (fp_line (start 8.4 -6.4) (end 8.4 7.4) (layer Dwgs.User) (width 0.12)) + (fp_line (start 8.4 7.4) (end -8.4 7.4) (layer Dwgs.User) (width 0.12)) + (fp_line (start -8.4 7.4) (end -8.4 -6.4) (layer Dwgs.User) (width 0.12)) + + + + (fp_line (start 9.8 7.3) (end 9.8 -6.3) (layer Edge.Cuts) (width 0.15)) + (fp_line (start 7.4 -6.3) (end 7.4 7.3) (layer Edge.Cuts) (width 0.15)) + (fp_line (start 9.5 -6.6) (end 7.7 -6.6) (layer Edge.Cuts) (width 0.15)) + (fp_line (start 7.7 7.6) (end 9.5 7.6) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start 7.7 7.3) (end 7.4 7.3) (angle -90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start 9.5 7.3) (end 9.5 7.6) (angle -90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start 7.7 -6.3) (end 7.7 -6.6) (angle -90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start 9.5 -6.3) (end 9.8 -6.3) (angle -90) (layer Edge.Cuts) (width 0.15)) + + + (pad S1 thru_hole circle (at -6.85 -6.2 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 1 "from")) + (pad S2 thru_hole circle (at -5 -6.2 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 2 "to")) + (pad A thru_hole circle (at -5.625 -3.81 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 11 "A")) + (pad B thru_hole circle (at -5.625 -1.27 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 12 "B")) + (pad C thru_hole circle (at -5.625 1.27 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 13 "C")) + (pad D thru_hole circle (at -5.625 3.81 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 14 "D")) + + + (pad "" np_thru_hole circle (at -5.625 6.3 0) (size 1.5 1.5) (drill 1.5) (layers *.Cu *.Mask)) + + + + (fp_line (start -9.8 7.3) (end -9.8 -6.3) (layer Edge.Cuts) (width 0.15)) + (fp_line (start -7.4 -6.3) (end -7.4 7.3) (layer Edge.Cuts) (width 0.15)) + (fp_line (start -9.5 -6.6) (end -7.7 -6.6) (layer Edge.Cuts) (width 0.15)) + (fp_line (start -7.7 7.6) (end -9.5 7.6) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start -7.7 7.3) (end -7.4 7.3) (angle 90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start -9.5 7.3) (end -9.5 7.6) (angle 90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start -7.7 -6.3) (end -7.7 -6.6) (angle 90) (layer Edge.Cuts) (width 0.15)) + (fp_arc (start -9.5 -6.3) (end -9.8 -6.3) (angle 90) (layer Edge.Cuts) (width 0.15)) + + + (pad S1 thru_hole circle (at 6.85 -6.2 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 1 "from")) + (pad S2 thru_hole circle (at 5 -6.2 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 2 "to")) + (pad A thru_hole circle (at 5.625 -3.81 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 11 "A")) + (pad B thru_hole circle (at 5.625 -1.27 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 12 "B")) + (pad C thru_hole circle (at 5.625 1.27 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 13 "C")) + (pad D thru_hole circle (at 5.625 3.81 0) (size 1.6 1.6) (drill 0.9) (layers *.Cu *.Mask) (net 14 "D")) + + + (pad "" np_thru_hole circle (at 5.625 6.3 0) (size 1.5 1.5) (drill 1.5) (layers *.Cu *.Mask)) + ) + + + + (module E73:SPDT_C128955 (layer F.Cu) (tstamp 5BF2CC3C) + + (at 100 -150 0) + + + (fp_text reference "T2" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + (fp_text value "" (at 0 0) (layer F.SilkS) hide (effects (font (size 1.27 1.27) (thickness 0.15)))) + + + (fp_line (start 1.95 -1.35) (end -1.95 -1.35) (layer B.SilkS) (width 0.15)) + (fp_line (start 0 -1.35) (end -3.3 -1.35) (layer B.SilkS) (width 0.15)) + (fp_line (start -3.3 -1.35) (end -3.3 1.5) (layer B.SilkS) (width 0.15)) + (fp_line (start -3.3 1.5) (end 3.3 1.5) (layer B.SilkS) (width 0.15)) + (fp_line (start 3.3 1.5) (end 3.3 -1.35) (layer B.SilkS) (width 0.15)) + (fp_line (start 0 -1.35) (end 3.3 -1.35) (layer B.SilkS) (width 0.15)) + + + (fp_line (start -1.95 -3.85) (end 1.95 -3.85) (layer Dwgs.User) (width 0.15)) + (fp_line (start 1.95 -3.85) (end 1.95 -1.35) (layer Dwgs.User) (width 0.15)) + (fp_line (start -1.95 -1.35) (end -1.95 -3.85) (layer Dwgs.User) (width 0.15)) + + + (pad "" np_thru_hole circle (at 1.5 0) (size 1 1) (drill 0.9) (layers *.Cu *.Mask)) + (pad "" np_thru_hole circle (at -1.5 0) (size 1 1) (drill 0.9) (layers *.Cu *.Mask)) + + + (pad 1 smd rect (at -2.25 2.075 0) (size 0.9 1.25) (layers B.Cu B.Paste B.Mask) (net 1 "from")) + (pad 2 smd rect (at 0.75 2.075 0) (size 0.9 1.25) (layers B.Cu B.Paste B.Mask) (net 2 "to")) + (pad 3 smd rect (at 2.25 2.075 0) (size 0.9 1.25) (layers B.Cu B.Paste B.Mask)) + + + (pad "" smd rect (at 3.7 -1.1 0) (size 0.9 0.9) (layers B.Cu B.Paste B.Mask)) + (pad "" smd rect (at 3.7 1.1 0) (size 0.9 0.9) (layers B.Cu B.Paste B.Mask)) + (pad "" smd rect (at -3.7 1.1 0) (size 0.9 0.9) (layers B.Cu B.Paste B.Mask)) + (pad "" smd rect (at -3.7 -1.1 0) (size 0.9 0.9) (layers B.Cu B.Paste B.Mask)) + ) + + ) diff --git a/test/helpers/mock_footprints.js b/test/helpers/mock_footprints.js index 749d26c..788628d 100644 --- a/test/helpers/mock_footprints.js +++ b/test/helpers/mock_footprints.js @@ -3,6 +3,7 @@ exports.inject = (ergogen) => { params: { designator: 'T', side: 'F', + width: 0.25, P1: {type: 'net', value: 'P1'} }, body: p => { @@ -20,7 +21,7 @@ exports.inject = (ergogen) => { ) - (segment (start ${p.sxy(0, 0)}) (end ${p.sxy(5, 5)}) (width 0.25) (layer ${p.side}.Cu) (net ${p.P1.index})) + (segment (start ${p.sxy(0, 0)}) (end ${p.sxy(5, 5)}) (width ${p.width}) (layer ${p.side}.Cu) (net ${p.P1.index})) ` } @@ -106,7 +107,7 @@ exports.inject = (ergogen) => { } }) - ergogen.inject('footprint', 'references_test', { + ergogen.inject('references_test', { params: {}, body: p => { return `references ${p.ref_hide ? 'hidden' : 'shown'}` diff --git a/test/index.js b/test/index.js index e1fc995..5d60974 100644 --- a/test/index.js +++ b/test/index.js @@ -56,7 +56,13 @@ const test = function(input_path) { fs.writeJSONSync(expected_path, output_part, {spaces: 4}) } } else { - output_part.should.deep.equal(expected) + if (a.type(output_part)() == 'string') { + const parse_out = output_part.replace(/(?:\r\n|\r|\n)/g,"\n") + const parse_exp = expected.replace(/(?:\r\n|\r|\n)/g,"\n") + parse_out.should.deep.equal(parse_exp) + } else { + output_part.should.deep.equal(expected) + } } } }) @@ -133,14 +139,19 @@ for (let w of cli_what) { ref_path = path.resolve(path.join(t, read(ref_path).trim())) } const comp_res = dircompare.compareSync(output_path, ref_path, { - compareContent: true + compareContent: true, + compareFileSync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareSync, + compareFileAsync: dircompare.fileCompareHandlers.lineBasedFileCompare.compareAsync, + ignoreLineEnding: true }) if (dump) { fs.moveSync(output_path, ref_path, {overwrite: true}) } else { fs.removeSync(output_path) } - actual_log.should.equal(ref_log) + const parse_act_log = actual_log.replace(/(?:\r\n|\r|\n)/g,"\n") + const parse_ref_log = ref_log.replace(/(?:\r\n|\r|\n)/g,"\n") + parse_act_log.should.equal(parse_ref_log) comp_res.same.should.be.true // deliberately incorrect execution } else { diff --git a/test/outlines/binding.yaml b/test/outlines/binding.yaml new file mode 100644 index 0000000..6fba506 --- /dev/null +++ b/test/outlines/binding.yaml @@ -0,0 +1,18 @@ +points: + zones: + matrix: + mirror: + ref: matrix_only_first + distance: 30 + columns: + only.rows: + first.bind: 0 + second.bind: [0,10,0,10] + third.bind: [10,0,10,0] + fourth.bind: [u, u/2, u/3, u/4] +outlines: + bound: + - what: rectangle + where: true + size: 20 + bound: true diff --git a/test/outlines/binding___outlines_bound_dxf.dxf b/test/outlines/binding___outlines_bound_dxf.dxf new file mode 100644 index 0000000..433dd5d --- /dev/null +++ b/test/outlines/binding___outlines_bound_dxf.dxf @@ -0,0 +1,338 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-10 +20 +-10 +11 +10 +21 +-10 +0 +LINE +8 +0 +10 +10 +20 +-10 +11 +10 +21 +9 +0 +LINE +8 +0 +10 +-10 +20 +9 +11 +-10 +21 +-10 +0 +LINE +8 +0 +10 +10 +20 +29 +11 +20 +21 +29 +0 +LINE +8 +0 +10 +20 +20 +9 +11 +10 +21 +9 +0 +LINE +8 +0 +10 +-10 +20 +9 +11 +-20 +21 +9 +0 +LINE +8 +0 +10 +-20 +20 +9 +11 +-20 +21 +29 +0 +LINE +8 +0 +10 +-20 +20 +29 +11 +-10 +21 +29 +0 +LINE +8 +0 +10 +10 +20 +29 +11 +10 +21 +40.6666667 +0 +LINE +8 +0 +10 +-10 +20 +29 +11 +-10 +21 +40.6666667 +0 +LINE +8 +0 +10 +-14.75 +20 +86 +11 +44.75 +21 +86 +0 +LINE +8 +0 +10 +10 +20 +40.6666667 +11 +20 +21 +40.6666667 +0 +LINE +8 +0 +10 +-10 +20 +40.6666667 +11 +-14.75 +21 +40.6666667 +0 +LINE +8 +0 +10 +-14.75 +20 +40.6666667 +11 +-14.75 +21 +86 +0 +LINE +8 +0 +10 +20 +20 +-10 +11 +40 +21 +-10 +0 +LINE +8 +0 +10 +40 +20 +-10 +11 +40 +21 +9 +0 +LINE +8 +0 +10 +20 +20 +9 +11 +20 +21 +-10 +0 +LINE +8 +0 +10 +40 +20 +29 +11 +50 +21 +29 +0 +LINE +8 +0 +10 +50 +20 +9 +11 +50 +21 +29 +0 +LINE +8 +0 +10 +50 +20 +9 +11 +40 +21 +9 +0 +LINE +8 +0 +10 +40 +20 +29 +11 +40 +21 +40.6666667 +0 +LINE +8 +0 +10 +20 +20 +29 +11 +20 +21 +40.6666667 +0 +LINE +8 +0 +10 +44.75 +20 +40.6666667 +11 +44.75 +21 +86 +0 +LINE +8 +0 +10 +44.75 +20 +40.6666667 +11 +40 +21 +40.6666667 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/outlines/outlines.yaml b/test/outlines/outlines.yaml index 351fff7..9c58ce3 100644 --- a/test/outlines/outlines.yaml +++ b/test/outlines/outlines.yaml @@ -17,10 +17,15 @@ outlines: size: cy bound: true fillet: - - what: outline - name: base + - name: base fillet: 2 scale: - - what: outline - name: fillet - scale: 0.5 \ No newline at end of file + - name: fillet + scale: 0.5 + combination: + - "base" + - "-scale" + - "~fillet" + expand: + - name: combination + expand: 1 diff --git a/test/outlines/outlines___outlines_combination_dxf.dxf b/test/outlines/outlines___outlines_combination_dxf.dxf new file mode 100644 index 0000000..557f735 --- /dev/null +++ b/test/outlines/outlines___outlines_combination_dxf.dxf @@ -0,0 +1,514 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +8.6 +20 +-6.6 +11 +8.6 +21 +-4.3 +0 +LINE +8 +0 +10 +8.6 +20 +12.8 +11 +8.6 +21 +23.6 +0 +LINE +8 +0 +10 +-6.6 +20 +-8.6 +11 +6.6 +21 +-8.6 +0 +LINE +8 +0 +10 +-8.6 +20 +-6.6 +11 +-8.6 +21 +23.6 +0 +LINE +8 +0 +10 +-6.6 +20 +25.6 +11 +6.6 +21 +25.6 +0 +LINE +8 +0 +10 +27.6 +20 +-6.6 +11 +27.6 +21 +23.6 +0 +LINE +8 +0 +10 +12.4 +20 +-8.6 +11 +25.6 +21 +-8.6 +0 +LINE +8 +0 +10 +10.4 +20 +-6.6 +11 +10.4 +21 +-4.3 +0 +LINE +8 +0 +10 +10.4 +20 +12.8 +11 +10.4 +21 +23.6 +0 +LINE +8 +0 +10 +12.4 +20 +25.6 +11 +25.6 +21 +25.6 +0 +LINE +8 +0 +10 +4.3 +20 +-3.3 +11 +4.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +-4.3 +11 +3.3 +21 +-4.3 +0 +LINE +8 +0 +10 +-4.3 +20 +-3.3 +11 +-4.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +12.8 +11 +3.3 +21 +12.8 +0 +LINE +8 +0 +10 +13.8 +20 +-3.3 +11 +13.8 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +-4.3 +11 +8.6 +21 +-4.3 +0 +LINE +8 +0 +10 +10.4 +20 +-4.3 +11 +12.8 +21 +-4.3 +0 +LINE +8 +0 +10 +5.2 +20 +-3.3 +11 +5.2 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +12.8 +11 +8.6 +21 +12.8 +0 +LINE +8 +0 +10 +10.4 +20 +12.8 +11 +12.8 +21 +12.8 +0 +ARC +8 +0 +10 +3.3 +20 +11.8 +40 +1 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +-3.3 +20 +11.8 +40 +1 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +-3.3 +20 +-3.3 +40 +1 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +3.3 +20 +-3.3 +40 +1 +50 +270 +51 +0 +0 +ARC +8 +0 +10 +12.8 +20 +11.8 +40 +1 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +6.2 +20 +11.8 +40 +1 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +6.2 +20 +-3.3 +40 +1 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +12.8 +20 +-3.3 +40 +1 +50 +270 +51 +0 +0 +ARC +8 +0 +10 +6.6 +20 +23.6 +40 +2 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +-6.6 +20 +23.6 +40 +2 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +-6.6 +20 +-6.6 +40 +2 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +6.6 +20 +-6.6 +40 +2 +50 +270 +51 +0 +0 +ARC +8 +0 +10 +25.6 +20 +23.6 +40 +2 +50 +0 +51 +90 +0 +ARC +8 +0 +10 +12.4 +20 +23.6 +40 +2 +50 +90 +51 +180 +0 +ARC +8 +0 +10 +12.4 +20 +-6.6 +40 +2 +50 +180 +51 +270 +0 +ARC +8 +0 +10 +25.6 +20 +-6.6 +40 +2 +50 +270 +51 +0 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/outlines/outlines___outlines_expand_dxf.dxf b/test/outlines/outlines___outlines_expand_dxf.dxf new file mode 100644 index 0000000..b129818 --- /dev/null +++ b/test/outlines/outlines___outlines_expand_dxf.dxf @@ -0,0 +1,410 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-6.6 +20 +-9.6 +11 +6.6 +21 +-9.6 +0 +ARC +8 +0 +10 +6.6 +20 +-6.6 +40 +3 +50 +270 +51 +345.164888 +0 +ARC +8 +0 +10 +12.4 +20 +-6.6 +40 +3 +50 +194.835112 +51 +270 +0 +LINE +8 +0 +10 +12.4 +20 +-9.6 +11 +25.6 +21 +-9.6 +0 +ARC +8 +0 +10 +25.6 +20 +-6.6 +40 +3 +50 +270 +51 +360 +0 +LINE +8 +0 +10 +28.6 +20 +-6.6 +11 +28.6 +21 +23.6 +0 +ARC +8 +0 +10 +25.6 +20 +23.6 +40 +3 +50 +0 +51 +90 +0 +LINE +8 +0 +10 +12.4 +20 +26.6 +11 +25.6 +21 +26.6 +0 +ARC +8 +0 +10 +12.4 +20 +23.6 +40 +3 +50 +90 +51 +165.164888 +0 +ARC +8 +0 +10 +6.6 +20 +23.6 +40 +3 +50 +14.835112 +51 +90 +0 +LINE +8 +0 +10 +-6.6 +20 +26.6 +11 +6.6 +21 +26.6 +0 +ARC +8 +0 +10 +-6.6 +20 +23.6 +40 +3 +50 +90 +51 +180 +0 +LINE +8 +0 +10 +-9.6 +20 +-6.6 +11 +-9.6 +21 +23.6 +0 +ARC +8 +0 +10 +-6.6 +20 +-6.6 +40 +3 +50 +180 +51 +270 +0 +LINE +8 +0 +10 +12.8 +20 +-3.3 +11 +12.8 +21 +11.8 +0 +LINE +8 +0 +10 +10.4 +20 +11.8 +11 +12.8 +21 +11.8 +0 +ARC +8 +0 +10 +10.4 +20 +12.8 +40 +1 +50 +205.8419331 +51 +270 +0 +ARC +8 +0 +10 +8.6 +20 +12.8 +40 +1 +50 +270 +51 +334.1580669 +0 +LINE +8 +0 +10 +6.2 +20 +11.8 +11 +8.6 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +-3.3 +11 +6.2 +21 +11.8 +0 +LINE +8 +0 +10 +6.2 +20 +-3.3 +11 +8.6 +21 +-3.3 +0 +ARC +8 +0 +10 +8.6 +20 +-4.3 +40 +1 +50 +25.8419331 +51 +90 +0 +ARC +8 +0 +10 +10.4 +20 +-4.3 +40 +1 +50 +90 +51 +154.1580669 +0 +LINE +8 +0 +10 +10.4 +20 +-3.3 +11 +12.8 +21 +-3.3 +0 +LINE +8 +0 +10 +3.3 +20 +-3.3 +11 +3.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +11.8 +11 +3.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +-3.3 +11 +-3.3 +21 +11.8 +0 +LINE +8 +0 +10 +-3.3 +20 +-3.3 +11 +3.3 +21 +-3.3 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/outlines/rectangles.yaml b/test/outlines/rectangles.yaml index 2982e5e..6cd7c2f 100644 --- a/test/outlines/rectangles.yaml +++ b/test/outlines/rectangles.yaml @@ -17,6 +17,7 @@ outlines: - mirror_matrix shift: [0, sy/2] size: [20, 40] + corner: 5 outside_rects: what: rectangle where: diff --git a/test/outlines/rectangles___outlines_outline_dxf.dxf b/test/outlines/rectangles___outlines_outline_dxf.dxf index 8de0346..101992d 100644 --- a/test/outlines/rectangles___outlines_outline_dxf.dxf +++ b/test/outlines/rectangles___outlines_outline_dxf.dxf @@ -67,7 +67,7 @@ LINE 11 10 21 -0 +5 0 LINE 8 @@ -135,7 +135,7 @@ LINE 10 30 20 -0 +5 11 30 21 @@ -145,14 +145,28 @@ LINE 8 0 10 -10 +15 20 0 11 -30 +25 21 0 0 +ARC +8 +0 +10 +25 +20 +5 +40 +5 +50 +270 +51 +360 +0 LINE 8 0 @@ -163,32 +177,74 @@ LINE 11 30 21 +35 +0 +ARC +8 +0 +10 +25 +20 +35 40 +5 +50 +0 +51 +90 0 LINE 8 0 10 -30 +25 20 40 11 -10 +15 21 40 0 +ARC +8 +0 +10 +15 +20 +35 +40 +5 +50 +90 +51 +180 +0 LINE 8 0 10 10 20 -40 +35 11 10 21 10 0 +ARC +8 +0 +10 +15 +20 +5 +40 +5 +50 +180 +51 +270 +0 LINE 8 0 diff --git a/test/pcbs/mock_footprints.yaml b/test/pcbs/mock_footprints.yaml index ddce5b0..8eb2df9 100644 --- a/test/pcbs/mock_footprints.yaml +++ b/test/pcbs/mock_footprints.yaml @@ -18,6 +18,7 @@ pcbs: shift: [1, 1] rotate: 30 params: + width: u/40 side: F mirror: side: B @@ -28,9 +29,13 @@ pcbs: rotate: 30 dyn: what: dynamic_net_test - anc: + anc1: what: anchor_test params: end: ref: matrix - shift: [10, 10] \ No newline at end of file + shift: [10, 10] + anc2: + what: anchor_test + params: + end: matrix diff --git a/test/pcbs/mock_footprints___pcbs_main.kicad_pcb b/test/pcbs/mock_footprints___pcbs_main.kicad_pcb index d9b38b3..37fc693 100644 --- a/test/pcbs/mock_footprints___pcbs_main.kicad_pcb +++ b/test/pcbs/mock_footprints___pcbs_main.kicad_pcb @@ -126,7 +126,7 @@ ) - (segment (start 1 -1) (end 7.830127 0.8301270000000001) (width 0.25) (layer F.Cu) (net 1)) + (segment (start 1 -1) (end 7.830127 0.8301270000000001) (width 0.475) (layer F.Cu) (net 1)) @@ -143,7 +143,7 @@ ) - (segment (start 19 -1) (end 12.169872999999999 0.8301270000000001) (width 0.25) (layer B.Cu) (net 1)) + (segment (start 19 -1) (end 12.169872999999999 0.8301270000000001) (width 0.475) (layer B.Cu) (net 1)) @@ -160,7 +160,7 @@ ) - (segment (start 19 -1) (end 12.169872999999999 0.8301270000000001) (width 0.25) (layer B.Cu) (net 1)) + (segment (start 19 -1) (end 12.169872999999999 0.8301270000000001) (width 0.475) (layer B.Cu) (net 1)) @@ -177,7 +177,7 @@ ) - (segment (start 1 -1) (end 7.830127 0.8301270000000001) (width 0.25) (layer F.Cu) (net 1)) + (segment (start 1 -1) (end 7.830127 0.8301270000000001) (width 0.475) (layer F.Cu) (net 1)) @@ -231,6 +231,17 @@ ) + + + (module anchor_test (layer F.Cu) (tedit 5CF31DEF) + + (at 0 0 0) + + (fp_line (start 0 0) (end 0 0) (layer Dwgs.User) (width 0.05)) + + ) + + (gr_line (start -9.5 9.5) (end 9.5 9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) (gr_line (start 9.5 9.5) (end 9.5 -9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) (gr_line (start 9.5 -9.5) (end -9.5 -9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) diff --git a/test/pcbs/outlines.yaml b/test/pcbs/outlines.yaml new file mode 100644 index 0000000..7a7cd82 --- /dev/null +++ b/test/pcbs/outlines.yaml @@ -0,0 +1,34 @@ +points.zones.matrix: + columns: + left: + right: + rows.only: +outlines: + left: + out: + what: rectangle + where: matrix_left_only + size: u + fillet: u/5 + in: + what: circle + where: matrix_left_only + radius: u/4 + operation: subtract + right: + out: + what: rectangle + where: matrix_right_only + size: u + bevel: u/5 + in: + what: rectangle + where: matrix_right_only + size: u/2 + bevel: u/4 + operation: subtract +pcbs: + main: + outlines: + - outline: 'left' + - outline: 'right' diff --git a/test/pcbs/outlines___pcbs_main.kicad_pcb b/test/pcbs/outlines___pcbs_main.kicad_pcb new file mode 100644 index 0000000..8e92c54 --- /dev/null +++ b/test/pcbs/outlines___pcbs_main.kicad_pcb @@ -0,0 +1,132 @@ + + +(kicad_pcb (version 20171130) (host pcbnew 5.1.6) + + (page A3) + (title_block + (title main) + (rev v1.0.0) + (company Unknown) + ) + + (general + (thickness 1.6) + ) + + (layers + (0 F.Cu signal) + (31 B.Cu signal) + (32 B.Adhes user) + (33 F.Adhes user) + (34 B.Paste user) + (35 F.Paste user) + (36 B.SilkS user) + (37 F.SilkS user) + (38 B.Mask user) + (39 F.Mask user) + (40 Dwgs.User user) + (41 Cmts.User user) + (42 Eco1.User user) + (43 Eco2.User user) + (44 Edge.Cuts user) + (45 Margin user) + (46 B.CrtYd user) + (47 F.CrtYd user) + (48 B.Fab user) + (49 F.Fab user) + ) + + (setup + (last_trace_width 0.25) + (trace_clearance 0.2) + (zone_clearance 0.508) + (zone_45_only no) + (trace_min 0.2) + (via_size 0.8) + (via_drill 0.4) + (via_min_size 0.4) + (via_min_drill 0.3) + (uvia_size 0.3) + (uvia_drill 0.1) + (uvias_allowed no) + (uvia_min_size 0.2) + (uvia_min_drill 0.1) + (edge_width 0.05) + (segment_width 0.2) + (pcb_text_width 0.3) + (pcb_text_size 1.5 1.5) + (mod_edge_width 0.12) + (mod_text_size 1 1) + (mod_text_width 0.15) + (pad_size 1.524 1.524) + (pad_drill 0.762) + (pad_to_mask_clearance 0.05) + (aux_axis_origin 0 0) + (visible_elements FFFFFF7F) + (pcbplotparams + (layerselection 0x010fc_ffffffff) + (usegerberextensions false) + (usegerberattributes true) + (usegerberadvancedattributes true) + (creategerberjobfile true) + (excludeedgelayer true) + (linewidth 0.100000) + (plotframeref false) + (viasonmask false) + (mode 1) + (useauxorigin false) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (psnegative false) + (psa4output false) + (plotreference true) + (plotvalue true) + (plotinvisibletext false) + (padsonsilk false) + (subtractmaskfromsilk false) + (outputformat 1) + (mirror false) + (drillshape 1) + (scaleselection 1) + (outputdirectory "")) + ) + + (net 0 "") + + (net_class Default "This is the default net class." + (clearance 0.2) + (trace_width 0.25) + (via_dia 0.8) + (via_drill 0.4) + (uvia_dia 0.3) + (uvia_drill 0.1) + (add_net "") + ) + + + (gr_line (start -5.7 9.5) (end 5.699999999999999 9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 9.5 5.7) (end 9.5 -5.699999999999999) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 5.699999999999999 -9.5) (end -5.7 -9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start -9.5 -5.699999999999999) (end -9.5 5.7) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_arc (start 5.7 5.7) (end 5.7 9.5) (angle -90) (layer Edge.Cuts) (width 0.15)) +(gr_arc (start 5.7 -5.7) (end 9.5 -5.7) (angle -90) (layer Edge.Cuts) (width 0.15)) +(gr_arc (start -5.7 -5.7) (end -5.7 -9.5) (angle -90) (layer Edge.Cuts) (width 0.15)) +(gr_arc (start -5.7 5.7) (end -9.5 5.7) (angle -90) (layer Edge.Cuts) (width 0.15)) +(gr_circle (center 0 0) (end 4.75 0) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 13.3 9.5) (end 9.5 5.7) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 9.5 5.7) (end 9.5 -5.7) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 9.5 -5.7) (end 13.3 -9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 13.3 -9.5) (end 24.700000000000003 -9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 24.700000000000003 -9.5) (end 28.5 -5.7) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 28.5 -5.7) (end 28.5 5.7) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 28.5 5.7) (end 24.700000000000003 9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 24.700000000000003 9.5) (end 13.3 9.5) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 19 4.75) (end 14.25 0) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 14.25 0) (end 19 -4.75) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 19 -4.75) (end 23.75 0) (angle 90) (layer Edge.Cuts) (width 0.15)) +(gr_line (start 23.75 0) (end 19 4.75) (angle 90) (layer Edge.Cuts) (width 0.15)) + +) + + \ No newline at end of file diff --git a/test/points/mirrors.yaml b/test/points/mirrors.yaml new file mode 100644 index 0000000..a38565b --- /dev/null +++ b/test/points/mirrors.yaml @@ -0,0 +1,15 @@ +points: + mirror: + ref: matrix_right_top + distance: U + zones: + matrix: + columns: + left: + rows: + bottom.asym: source + top.asym: clone + right: + rows: + bottom: + top: diff --git a/test/points/mirrors___demo_dxf.dxf b/test/points/mirrors___demo_dxf.dxf new file mode 100644 index 0000000..799f5bd --- /dev/null +++ b/test/points/mirrors___demo_dxf.dxf @@ -0,0 +1,338 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-9 +20 +9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +-9 +21 +-9 +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +-9 +21 +9 +0 +LINE +8 +0 +10 +10 +20 +9 +11 +28 +21 +9 +0 +LINE +8 +0 +10 +28 +20 +9 +11 +28 +21 +-9 +0 +LINE +8 +0 +10 +28 +20 +-9 +11 +10 +21 +-9 +0 +LINE +8 +0 +10 +10 +20 +-9 +11 +10 +21 +9 +0 +LINE +8 +0 +10 +10 +20 +28 +11 +28 +21 +28 +0 +LINE +8 +0 +10 +28 +20 +28 +11 +28 +21 +10 +0 +LINE +8 +0 +10 +28 +20 +10 +11 +10 +21 +10 +0 +LINE +8 +0 +10 +10 +20 +10 +11 +10 +21 +28 +0 +LINE +8 +0 +10 +48.05 +20 +28 +11 +66.05 +21 +28 +0 +LINE +8 +0 +10 +66.05 +20 +28 +11 +66.05 +21 +10 +0 +LINE +8 +0 +10 +66.05 +20 +10 +11 +48.05 +21 +10 +0 +LINE +8 +0 +10 +48.05 +20 +10 +11 +48.05 +21 +28 +0 +LINE +8 +0 +10 +29.05 +20 +9 +11 +47.05 +21 +9 +0 +LINE +8 +0 +10 +47.05 +20 +9 +11 +47.05 +21 +-9 +0 +LINE +8 +0 +10 +47.05 +20 +-9 +11 +29.05 +21 +-9 +0 +LINE +8 +0 +10 +29.05 +20 +-9 +11 +29.05 +21 +9 +0 +LINE +8 +0 +10 +29.05 +20 +28 +11 +47.05 +21 +28 +0 +LINE +8 +0 +10 +47.05 +20 +28 +11 +47.05 +21 +10 +0 +LINE +8 +0 +10 +47.05 +20 +10 +11 +29.05 +21 +10 +0 +LINE +8 +0 +10 +29.05 +20 +10 +11 +29.05 +21 +28 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/points/rotations.yaml b/test/points/rotations.yaml new file mode 100644 index 0000000..50ffa01 --- /dev/null +++ b/test/points/rotations.yaml @@ -0,0 +1,16 @@ +points: + rotate: 22.5 + zones: + matrix: + rotate: 22.5 + key: + origin: [-u/2, -u/2] + columns: + left: + right.key: + rotate: -45 + padding: (1+sqrt(2))/2 * u + spread: (1+sqrt(2))/2 * u + rows: + bottom: + top: diff --git a/test/points/rotations___demo_dxf.dxf b/test/points/rotations___demo_dxf.dxf new file mode 100644 index 0000000..657e493 --- /dev/null +++ b/test/points/rotations___demo_dxf.dxf @@ -0,0 +1,242 @@ +0 +SECTION +2 +HEADER +9 +$INSUNITS +70 +4 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +0 +LTYPE +72 +65 +70 +64 +2 +CONTINUOUS +3 +______ +73 +0 +40 +0 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +10 +-12.7279221 +20 +0 +11 +0 +21 +12.7279221 +0 +LINE +8 +0 +10 +0 +20 +12.7279221 +11 +12.7279221 +21 +0 +0 +LINE +8 +0 +10 +12.7279221 +20 +0 +11 +0 +21 +-12.7279221 +0 +LINE +8 +0 +10 +0 +20 +-12.7279221 +11 +-12.7279221 +21 +0 +0 +LINE +8 +0 +10 +-26.1629509 +20 +13.4350288 +11 +-13.4350288 +21 +26.1629509 +0 +LINE +8 +0 +10 +-13.4350288 +20 +26.1629509 +11 +-0.7071067 +21 +13.4350288 +0 +LINE +8 +0 +10 +-0.7071067 +20 +13.4350288 +11 +-13.4350288 +21 +0.7071067 +0 +LINE +8 +0 +10 +-13.4350288 +20 +0.7071067 +11 +-26.1629509 +21 +13.4350288 +0 +LINE +8 +0 +10 +7.2175144 +20 +25.2175144 +11 +25.2175144 +21 +25.2175144 +0 +LINE +8 +0 +10 +25.2175144 +20 +25.2175144 +11 +25.2175144 +21 +7.2175144 +0 +LINE +8 +0 +10 +25.2175144 +20 +7.2175144 +11 +7.2175144 +21 +7.2175144 +0 +LINE +8 +0 +10 +7.2175144 +20 +7.2175144 +11 +7.2175144 +21 +25.2175144 +0 +LINE +8 +0 +10 +16.2175144 +20 +51.8804653 +11 +28.9454365 +21 +39.1525432 +0 +LINE +8 +0 +10 +28.9454365 +20 +39.1525432 +11 +16.2175144 +21 +26.4246211 +0 +LINE +8 +0 +10 +16.2175144 +20 +26.4246211 +11 +3.4895923 +21 +39.1525432 +0 +LINE +8 +0 +10 +3.4895923 +20 +39.1525432 +11 +16.2175144 +21 +51.8804653 +0 +ENDSEC +0 +EOF \ No newline at end of file diff --git a/test/unit/anchor.js b/test/unit/anchor.js index c9b3dd1..d32c981 100644 --- a/test/unit/anchor.js +++ b/test/unit/anchor.js @@ -56,6 +56,21 @@ describe('Anchor', function() { }, 'name', points)(), [5, 5, -45, {}] ) + // empty parts + check( + parse({ + aggregate: { + } + }, 'name', points)(), + [0, 0, 0, {}] + ) + // can't have aggregate and ref together + parse({ + aggregate: { + parts: ['o', 'ten'] + }, + ref : 'ten' + }, 'name', points).should.throw() }) it('shift', function() { diff --git a/test/unit/filter.js b/test/unit/filter.js index 5481949..6097150 100644 --- a/test/unit/filter.js +++ b/test/unit/filter.js @@ -4,6 +4,12 @@ const Point = require('../../src/point') describe('Filter', function() { + it('empty', function() { + filter(undefined, '').should.deep.equal([new Point()]) + filter(true, '').should.deep.equal([]) + filter(false, '').should.deep.equal([]) + }) + const points = { one: new Point(0, 1, 0, {name: 'one', tags: ['odd']}), two: new Point(0, 2, 0, {name: 'two', tags: ['even', 'prime']}), @@ -18,8 +24,15 @@ describe('Filter', function() { // true shouldn't filter anything, while false should filter everything filter(true, '', points).should.deep.equal(Object.values(points)) filter(false, '', points).should.deep.equal([]) + // points should only be returned on their respective halves + filter(true, '', points, undefined, 'source').should.deep.equal(Object.values(points)) + filter(true, '', points, undefined, 'clone').should.deep.equal([]) + filter(true, '', points, undefined, 'both').should.deep.equal(Object.values(points)) // objects just propagate to anchor (and then wrap in array for consistency) filter({}, '', points).should.deep.equal([anchor({}, '', points)()]) + filter({}, '', points, undefined, 'source').should.deep.equal([anchor({}, '', points)()]) + filter({}, '', points, undefined, 'clone').should.deep.equal([anchor({}, '', points)()]) + filter({}, '', points, undefined, 'both').should.deep.equal([anchor({}, '', points)(), anchor({}, '', points)()]) // simple name string names(filter('one', '', points)).should.deep.equal(['one']) // simple name regex @@ -42,4 +55,4 @@ describe('Filter', function() { filter.bind(this, 28, '', points).should.throw('Unexpected type') }) -}) \ No newline at end of file +}) diff --git a/test/unit/interface.js b/test/unit/interface.js index ddae923..af93712 100644 --- a/test/unit/interface.js +++ b/test/unit/interface.js @@ -10,7 +10,8 @@ const load = name => yaml.safeLoad(fs.readFileSync( ).toString()) const minimal = load('minimal.yaml') const big = load('big.yaml') -const kle = load('atreus_kle.json') +const minimal_kle = load('minimal_kle.json') +const atreus_kle = load('atreus_kle.json') describe('Interface', function() { @@ -49,7 +50,8 @@ describe('Interface', function() { //: return 'not an object'; `, true, logger).should.be.rejectedWith('not valid'), - ergogen.process(kle, true, logger).should.be.rejectedWith('KLE'), + ergogen.process(minimal_kle, true, logger).should.be.rejectedWith('KLE'), + ergogen.process(atreus_kle, true, logger).should.be.rejectedWith('KLE'), ergogen.process('not an object', true, logger).should.be.rejectedWith('object'), ergogen.process({}, true, logger).should.be.rejectedWith('empty'), ergogen.process({not_points: {}}, true, () => {}).should.be.rejectedWith('points clause'), diff --git a/test/unit/units.js b/test/unit/units.js index 2da81dc..ac1e947 100644 --- a/test/unit/units.js +++ b/test/unit/units.js @@ -5,12 +5,19 @@ describe('Units', function() { it('defaults', function() { // check that an empty config has the default units (and nothing more) - const def = u.parse({}) - Object.keys(def).filter(public).length.should.equal(4) - def.U.should.equal(19.05) - def.u.should.equal(19) - def.cx.should.equal(18) - def.cy.should.equal(17) + const def1 = u.parse({}) + Object.keys(def1).filter(public).length.should.equal(4) + def1.U.should.equal(19.05) + def1.u.should.equal(19) + def1.cx.should.equal(18) + def1.cy.should.equal(17) + // check that an empty config has the default units (and nothing more) + const def2 = u.parse() + Object.keys(def2).filter(public).length.should.equal(4) + def2.U.should.equal(19.05) + def2.u.should.equal(19) + def2.cx.should.equal(18) + def2.cy.should.equal(17) }) it('units', function() { @@ -47,4 +54,4 @@ describe('Units', function() { res.a.should.equal(20.05) }) -}) \ No newline at end of file +})