omdl  v1.0
OpenSCAD Mechanical Design Library
validation.scad
Go to the documentation of this file.
1 //! Methods for validating the results of functions.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2015-2024
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  \amu_define group_name (Validation Functions)
31  \amu_define group_brief (Run-time test and validation functions.)
32 
33  \amu_include (include/amu/doxyg_init_pd_gds_ipg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/doxyg_define_in_parent_open.amu)
42  \amu_include (include/amu/includes_required.amu)
43 *******************************************************************************/
44 
45 //----------------------------------------------------------------------------//
46 // common
47 //----------------------------------------------------------------------------//
48 
49 //! Value signature assignment for log-value results table to skip a test.
50 validation_skip = "__skip__";
51 
52 //! \name Common
53 //! @{
54 
55 //! Compare a computed test value with an known good result.
56 /***************************************************************************//**
57  \param d <string> A description.
58  \param cv <value> A computed value to validate.
59  \param t <string | boolean> The validation type.
60  \param ev <value> The expected good value.
61 
62  \param p <number> A numerical precision for approximate comparisons.
63 
64  \param pf <boolean> Report result as pass or fail boolean value.
65 
66  \returns <string | boolean> Validation result indicating if the test
67  passed or failed.
68 
69  \details
70 
71  validation types | pass if (else fail)
72  :----------------------------:|:----------------------------:
73  "ae" \| "almost" | cv almost equals ev
74  "eq" \| "equals" | cv equals ev
75  "ne" \| "not" | cv not equal to ev
76  "t" \| "true" \| true | cv is true
77  "f" \| "false" \| false | cv is false
78 
79  \note When performing an \b "almost" equal validation, the
80  comparison precision is controlled by \p p. This specifies
81  the number of digits of precision for each numerical
82  comparison. A passing result indicates that \p cv equals
83  \p ev to the number of decimal digits specified by \p p. The
84  comparison is performed by the function almost_eq().
85 
86  \amu_define title (Validate function)
87  \amu_define scope_id (example_validate)
88  \amu_include (include/amu/scope.amu)
89 *******************************************************************************/
90 function validate
91 (
92  d,
93  cv,
94  t,
95  ev,
96  p = 6,
97  pf = false
98 ) = ( (t == "eq") || (t == "equals") ) ?
99  (
100  (cv == ev)
101  ? (pf?true : str("PASSED: '", d, "'"))
102  : (pf?false : str
103  (
104  "FAILED: '", d, "'; got '", cv,
105  "', expected to equal '", ev, "'."
106  )
107  )
108  )
109  : ( (t == "ne") || (t == "not") ) ?
110  (
111  (cv != ev)
112  ? (pf?true : str("PASSED: '", d, "'"))
113  : (pf?false : str
114  (
115  "FAILED: '", d, "'; got '", cv,
116  "', expected to not equal '", ev, "'."
117  )
118  )
119  )
120  : ( (t == true) || (t == "true") || (t == "t") ) ? validate(d, cv, "equals", true, p, pf)
121  : ( (t == false) || (t == "false") || (t == "f") ) ? validate(d, cv, "equals", false, p, pf)
122  : ( (t == "ae") || (t == "almost") ) ?
123  (
124  almost_eq(cv, ev, p)
125  ? (pf?true : str("PASSED: '", d, "'"))
126  : (pf?false : str
127  (
128  "FAILED: '", d, "'; got '", cv,
129  "', expected to almost equal '", ev, "'.",
130  " to ", p, " digits"
131  )
132  )
133  )
134  : (pf?false : str("FAILED: '", d, "'; unknown test '", t, "'."));
135 
136 //! Output text \p t to the test log.
137 /***************************************************************************//**
138  \param t <string> A message to output to log.
139 *******************************************************************************/
140 module validate_log( t ) { log_type ( "omdl_test", t ); }
141 
142 //! Output that function named \p fn has been skipped to the test log.
143 /***************************************************************************//**
144  \param fn <string> The name of the skipped function.
145 *******************************************************************************/
146 module validate_skip( fn ) { validate_log ( str("ignore: '", fn, "'") ); }
147 
148 //! @}
149 
150 //----------------------------------------------------------------------------//
151 // validation tables
152 //----------------------------------------------------------------------------//
153 
154 //! \name Validation Tables
155 //! @{
156 
157 //! Create data structure for related table validation functions.
158 /***************************************************************************//**
159  \param tr <table> The test data table rows.
160  \param gr <table> The expected result data table rows.
161 
162  \returns <datastruct> A structure used with the related table
163  validation functions.
164 *******************************************************************************/
165 function table_validate_init
166 (
167  tr,
168  gr
169 ) = let
170  (
171  ids = table_get_row_ids( tr )
172  )
173  [
174  tr, // db[0] test row
175  [["id","identifier"],["td","description"],["vl","value-list"]], // db[1] test data columns
176  gr, // db[2] good result row
177  merge_p([concat("id",ids),concat("identifier",ids)]) // db[3] good result columns
178  ];
179 
180 //! Encode an entry for test table.
181 /***************************************************************************//**
182  \param id <string> The test identifier.
183  \param td <string> The test description.
184  \param v1 <value> The test argument value 1.
185  \param v2 <value> The test argument value 1.
186  \param v3 <value> The test argument value 1.
187 
188  \returns <datastruct> An test table entry.
189 *******************************************************************************/
190 function table_validate_fmt
191 (
192  id,
193  td,
194  v1,
195  v2,
196  v3
197 ) = !is_undef(v2) && !is_undef(v3) ? [id, td, [v1, v2, v3]]
198  : !is_undef(v2) ? [id, td, [v1, v2]]
199  : [id, td, [v1]];
200 
201 //! Return a list of test identifiers in \p db.
202 /***************************************************************************//**
203  \param db <datastruct> An initialized validation table data structure.
204 
205  \returns <list> A list of test identifiers.
206 *******************************************************************************/
207 function table_validate_get_ids( db ) = table_get_row_ids( db[0] );
208 
209 //! Return the expected value.
210 /***************************************************************************//**
211  \param db <datastruct> An initialized validation table data structure.
212  \param fn <string> The function name.
213  \param id <string> The test identifier.
214 
215  \returns <value> The expect value.
216 *******************************************************************************/
217 function table_validate_get_ev( db, fn, id ) = table_get_value(db[2], db[3], fn, id);
218 
219 //! Return the test description.
220 /***************************************************************************//**
221  \param db <datastruct> An initialized validation table data structure.
222  \param id <string> The test identifier.
223 
224  \returns <value> The test description.
225 *******************************************************************************/
226 function table_validate_get_td( db, id ) = table_get_value(db[0], db[1], id, "td");
227 
228 //! Return the test argument value 1.
229 /***************************************************************************//**
230  \param db <datastruct> An initialized validation table data structure.
231  \param id <string> The test identifier.
232 
233  \returns <value> The test argument value 1.
234 *******************************************************************************/
235 function table_validate_get_v1( db, id ) = first(table_get_value(db[0], db[1], id, "vl"));
236 
237 //! Return the test argument value 2.
238 /***************************************************************************//**
239  \param db <datastruct> An initialized validation table data structure.
240  \param id <string> The test identifier.
241 
242  \returns <value> The test argument value 2.
243 *******************************************************************************/
244 function table_validate_get_v2( db, id ) = second(table_get_value(db[0], db[1], id, "vl"));
245 
246 //! Return the test argument value 3.
247 /***************************************************************************//**
248  \param db <datastruct> An initialized validation table data structure.
249  \param id <string> The test identifier.
250 
251  \returns <value> The test argument value 3.
252 *******************************************************************************/
253 function table_validate_get_v3( db, id ) = third(table_get_value(db[0], db[1], id, "vl"));
254 
255 //! Test data structure \p db and output the start of test to the test log.
256 /***************************************************************************//**
257  \param db <datastruct> An initialized validation table data structure.
258  \param verbose <boolean> Be more verbose.
259 *******************************************************************************/
260 module table_validate_start( db, verbose=false )
261 {
262  if ( verbose )
263  validate_log( "checking data structure" );
264 
265  // check test table
266  table_check( db[0], db[1], verbose );
267 
268  // check expected result table
269  table_check( db[2], db[3], verbose );
270 
271  validate_log( str("openscad version ", version()) );
272 }
273 
274 //! Validate and log a test function return value against its expected value.
275 /***************************************************************************//**
276  \param db <datastruct> An initialized validation table data structure.
277  \param id <string> The test identifier.
278  \param fn <string> The function name.
279  \param argc <integer> The number of arguments to retrieve from \p db.
280  \param fr <value> The value returned from the tested function.
281  \param t <string | boolean> The validation type.
282  \param p <number> A numerical precision for approximate comparisons.
283 
284  \details
285 
286  See function validate() for more information on possible values for
287  parameters \p t and \p p.
288 
289  \amu_define title (Table-based validation)
290  \amu_define scope_id (example_table)
291  \amu_include (include/amu/scope.amu)
292 *******************************************************************************/
293 module table_validate
294 (
295  db,
296  id,
297  fn,
298  argc,
299  fr,
300  t = "equals",
301  p = 6
302 )
303 {
304  td = table_validate_get_td(db, id);
305  ev = table_validate_get_ev(db, fn, id);
306 
307  if ( ev != validation_skip )
308  {
309  vd = (argc == 3) ? str(fn, "(", table_validate_get_v1(db, id),
310  ",", table_validate_get_v2(db, id),
311  ",", table_validate_get_v3(db, id), ")=", ev)
312  : (argc == 2) ? str(fn, "(", table_validate_get_v1(db, id),
313  ",", table_validate_get_v2(db, id), ")=", ev)
314  : (argc == 1) ? str(fn, "(", table_validate_get_v1(db, id), ")=", ev)
315  : str(fn, "(*)=", ev);
316 
317  lm = validate( d=vd, cv=fr, t=t, p=p, ev=ev );
318 
319  if ( !validate( cv=fr, t=t, p=p, ev=ev, pf=true ) )
320  validate_log( str(id, " ", lm, " ---> \"", td, "\"") );
321  else
322  validate_log( str(id, " ", lm) );
323  }
324  else
325  validate_log( str(id, " -skip-: '", fn, "(", td, ")'") );
326 }
327 
328 //! @}
329 
330 //----------------------------------------------------------------------------//
331 // validation maps
332 //----------------------------------------------------------------------------//
333 
334 //! \name Validation Tables
335 //! @{
336 
337 //! Create data structure for related map validation functions.
338 /***************************************************************************//**
339  \param m <map> The test data map.
340  \param fn <string> The function name.
341 
342  \returns <datastruct> A structure used with the related map
343  validation functions.
344 *******************************************************************************/
345 function map_validate_init
346 (
347  m,
348  fn
349 ) =
350  [
351  m, // db[0] test map
352  fn // db[1] function name
353  ];
354 
355 //! Encode an entry for test map.
356 /***************************************************************************//**
357  \param id <string> The test identifier.
358  \param td <string> The test description.
359  \param ev <value> The test expect value.
360  \param v1 <value> The test argument value 1.
361  \param v2 <value> The test argument value 2.
362  \param v3 <value> The test argument value 3.
363 
364  \returns <datastruct> An test map entry.
365 *******************************************************************************/
366 function map_validate_fmt
367 (
368  id,
369  td,
370  ev,
371  v1,
372  v2,
373  v3
374 ) = !is_undef(v2) && !is_undef(v3) ? [id, [td, ev, [v1, v2, v3]]]
375  : !is_undef(v2) ? [id, [td, ev, [v1, v2]]]
376  : [id, [td, ev, [v1]]];
377 
378 //! Return a list of test identifiers in \p db.
379 /***************************************************************************//**
380  \param db <datastruct> An initialized validation map data structure.
381 
382  \returns <list> A list of test identifiers.
383 *******************************************************************************/
384 function map_validate_get_ids( db ) = map_get_keys(db[0]);
385 
386 
387 //! Return the test function name.
388 /***************************************************************************//**
389  \param db <datastruct> An initialized validation map data structure.
390 
391  \returns <string> The test function name.
392 *******************************************************************************/
393 function map_validate_get_fn( db ) = db[1];
394 
395 //! Return the test description.
396 /***************************************************************************//**
397  \param db <datastruct> An initialized validation map data structure.
398  \param id <string> The test identifier.
399 
400  \returns <string> The test description for a given test \p id.
401 *******************************************************************************/
402 function map_validate_get_td( db, id ) = map_get_value(db[0], id)[0];
403 
404 //! Return the expected value.
405 /***************************************************************************//**
406  \param db <datastruct> An initialized validation map data structure.
407  \param id <string> The test identifier.
408 
409  \returns <value> The expect value.
410 *******************************************************************************/
411 function map_validate_get_ev( db, id ) = map_get_value(db[0], id)[1];
412 
413 //! Return the test argument value 1.
414 /***************************************************************************//**
415  \param db <datastruct> An initialized validation map data structure.
416  \param id <string> The test identifier.
417 
418  \returns <value> The argument value 1.
419 *******************************************************************************/
420 function map_validate_get_v1( db, id ) = first(map_get_value(db[0], id)[2]);
421 
422 //! Return the test argument value 2.
423 /***************************************************************************//**
424  \param db <datastruct> An initialized validation map data structure.
425  \param id <string> The test identifier.
426 
427  \returns <value> The argument value 2.
428 *******************************************************************************/
429 function map_validate_get_v2( db, id ) = second(map_get_value(db[0], id)[2]);
430 
431 //! Return the test argument value 3.
432 /***************************************************************************//**
433  \param db <datastruct> An initialized validation map data structure.
434  \param id <string> The test identifier.
435 
436  \returns <value> The argument value 3.
437 *******************************************************************************/
438 function map_validate_get_v3( db, id ) = third(map_get_value(db[0], id)[2]);
439 
440 //! Test data structure \p db and output the start of test to the test log.
441 /***************************************************************************//**
442  \param db <datastruct> An initialized validation map data structure.
443  \param verbose <boolean> Be more verbose.
444 *******************************************************************************/
445 module map_validate_start( db, verbose=false )
446 {
447  if ( verbose )
448  validate_log( "checking data structure" );
449 
450  // check map
451  map_check( db[0], verbose );
452 
453  validate_log( str("openscad version ", version()) );
454  validate_log( str(map_validate_get_fn(db), "()") );
455 }
456 
457 //! Validate and log a test function return value against its expected value.
458 /***************************************************************************//**
459  \param db <datastruct> An initialized validation map data structure.
460  \param id <string> The test identifier.
461  \param argc <integer> The number of arguments to retrieve from \p db.
462  \param fr <value> The value returned from the tested function.
463  \param t <string | boolean> The validation type.
464  \param p <number> A numerical precision for approximate comparisons.
465 
466  \details
467 
468  See function validate() for more information on possible values for
469  parameters \p t and \p p.
470 
471  \amu_define title (Map-based validation)
472  \amu_define scope_id (example_map)
473  \amu_include (include/amu/scope.amu)
474 *******************************************************************************/
475 module map_validate
476 (
477  db,
478  id,
479  argc,
480  fr,
481  t = "equals",
482  p = 6
483 )
484 {
485  fn = map_validate_get_fn(db);
486 
487  td = map_validate_get_td(db, id);
488  ev = map_validate_get_ev(db, id);
489 
490  if ( ev != validation_skip )
491  {
492  vd = (argc == 3) ? str(fn, "(", map_validate_get_v1(db, id),
493  ",", map_validate_get_v2(db, id),
494  ",", map_validate_get_v3(db, id), ")=", ev)
495  : (argc == 2) ? str(fn, "(", map_validate_get_v1(db, id),
496  ",", map_validate_get_v2(db, id), ")=", ev)
497  : (argc == 1) ? str(fn, "(", map_validate_get_v1(db, id), ")=", ev)
498  : str(fn, "(*)=", ev);
499 
500  lm = validate( d=vd, cv=fr, t=t, p=p, ev=ev );
501 
502  if ( !validate( cv=fr, t=t, p=p, ev=ev, pf=true ) )
503  validate_log( str(id, " ", lm, " ---> \"", td, "\"") );
504  else
505  validate_log( str(id, " ", lm) );
506  }
507  else
508  validate_log( str(id, " -skip-: '", fn, "(", td, ")'") );
509 }
510 
511 //! @}
512 
513 //! @}
514 //! @}
515 
516 //----------------------------------------------------------------------------//
517 // openscad-amu auxiliary scripts
518 //----------------------------------------------------------------------------//
519 
520 /*
521 BEGIN_SCOPE example_validate;
522  BEGIN_OPENSCAD;
523  include <omdl-base.scad>;
524  include <common/validation.scad>;
525 
526  //
527  // function to validate
528  //
529  function f1( x ) = (x == undef) ? 1 : 2;
530 
531  farg = undef; // function test argument
532  erv1 = 1; // correct expected function result
533  erv2 = 3; // incorrect expected function result
534 
535  //
536  // pass test example
537  //
538  log_type( "EXAMPLE 1", "pass test example" );
539 
540  pass_result = validate("test-a f1(farg)", f1(farg), "equals", erv1);
541 
542  if ( !validate(cv=f1(farg), t="equals", ev=erv1, pf=true) )
543  log_warn( pass_result );
544  else
545  log_info( pass_result );
546 
547  //
548  // fail test example
549  //
550  log_type( "EXAMPLE 2", "fail test example" );
551 
552  fail_result = validate("test-b f1(farg)", f1(farg), "equals", erv2);
553 
554  if ( !validate(cv=f1(farg), t="equals", ev=erv2, pf=true) )
555  log_warn( fail_result );
556  else
557  log_info( fail_result );
558 
559  //
560  // almost equal test example
561  //
562  log_type( "EXAMPLE 3", "almost equal test example" );
563 
564  tvae1 = [[90.001], [[45.009], true]];
565  tvae2 = [[90.002], [[45.010], true]];
566 
567  log_type( "EXAMPLE 3", "almost equal to 3 digits" );
568  log_info( validate("test-c", tvae1, "almost", tvae2, 3) );
569 
570  log_type( "EXAMPLE 3", "almost equal to 4 digits" );
571  log_info( validate("test-d", tvae1, "almost", tvae2, 4) );
572 
573  // end_include
574  END_OPENSCAD;
575 
576  BEGIN_MFSCRIPT;
577  include --path "${INCLUDE_PATH}" {var_init,var_gen_term}.mfs;
578  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
579  END_MFSCRIPT;
580 END_SCOPE;
581 
582 BEGIN_SCOPE example_table;
583  BEGIN_OPENSCAD;
584  include <omdl-base.scad>;
585  include <common/validation.scad>;
586 
587  function fmt( id, td, v1, v2, v3 ) = table_validate_fmt(id, td, v1, v2, v3);
588  function v1(db, id) = table_validate_get_v1(db, id);
589  t = true; f = false; u = undef; s = validation_skip;
590 
591  // table: test values
592  tbl_test_values =
593  [
594  fmt("t01", "The undefined value", undef),
595  fmt("t02", "A small decimal (epsilon)", eps),
596  fmt("t03", "The max number", number_max),
597  fmt("t04", "The invalid number nan", 0 / 0),
598  fmt("t05", "The boolean true", true),
599  fmt("t06", "A string", "This is a longer string"),
600  fmt("t07", "The empty string", empty_str),
601  fmt("t08", "The empty list", empty_lst),
602  fmt("t09", "A list of lists", [[1,2,3], [4,5,6], [7,8,9]]),
603  fmt("t10", "A range", [0:0.5:9])
604  ];
605 
606  // table: expected results: use 's' to skip
607  tbl_test_answers =
608  [ // function 01 02 03 04 05 06 07 08 09 101
609  ["is_bool", f, f, f, f, f, f, f, f, f, t],
610  ["is_string", f, f, f, f, f, f, f, f, f, f],
611  ["is_list", f, f, f, f, f, f, f, f, f, f]
612  ];
613 
614  db = table_validate_init( tbl_test_values, tbl_test_answers );
615 
616  table_validate_start( db );
617  test_ids = table_validate_get_ids( db );
618 
619  for (id=test_ids) table_validate( db, id, "is_bool", 1, is_bool( v1(db, id) ) );
620  for (id=test_ids) table_validate( db, id, "is_string", 1, is_string( v1(db, id) ) );
621  for (id=test_ids) table_validate( db, id, "is_list", 1, is_list( v1(db, id) ) );
622 
623  // end_include
624  END_OPENSCAD;
625 
626  BEGIN_MFSCRIPT;
627  include --path "${INCLUDE_PATH}" {var_init,var_gen_term}.mfs;
628  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
629  END_MFSCRIPT;
630 END_SCOPE;
631 
632 BEGIN_SCOPE example_map;
633  BEGIN_OPENSCAD;
634  include <omdl-base.scad>;
635  include <common/validation.scad>;
636 
637  function fmt( id, td, ev, v1, v2, v3 ) = map_validate_fmt(id, td, ev, v1, v2, v3);
638  function v1( db, id ) = map_validate_get_v1(db, id);
639  function v2( db, id ) = map_validate_get_v2(db, id);
640 
641  map_test_defined_or =
642  [
643  fmt("t01", "Undefined", 1, undef, 1),
644  fmt("t02", "A small value", eps, eps, 2),
645  fmt("t03", "Infinity", number_inf, number_inf, 3),
646  fmt("t04", "Max number", number_max, number_max, 4),
647  fmt("t05", "Undefined list", [undef], [undef], 5),
648  fmt("t06", "Short range", [0:9], [0:9], 6),
649  fmt("t07", "Empty string", empty_str, empty_str, 7),
650  fmt("t08", "Empty list", empty_lst, empty_lst, 8)
651  ];
652 
653  db = map_validate_init( map_test_defined_or, "defined_or" );
654  map_validate_start( db );
655 
656  for ( id = map_validate_get_ids( db ) )
657  map_validate( db, id, 2, defined_or ( v1(db, id), v2(db, id) ) );
658 
659  // end_include
660  END_OPENSCAD;
661 
662  BEGIN_MFSCRIPT;
663  include --path "${INCLUDE_PATH}" {var_init,var_gen_term}.mfs;
664  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
665  END_MFSCRIPT;
666 END_SCOPE;
667 */
668 
669 //----------------------------------------------------------------------------//
670 // end of file
671 //----------------------------------------------------------------------------//
module log_type(t, m)
Output diagnostic message to console.
Definition: console.scad:284
function map_validate_init(m, fn)
Create data structure for related map validation functions.
function map_validate_get_fn(db)
Return the test function name.
module table_validate_start(db, verbose=false)
Test data structure db and output the start of test to the test log.
function map_validate_fmt(id, td, ev, v1, v2, v3)
Encode an entry for test map.
module validate_skip(fn)
Output that function named fn has been skipped to the test log.
function validate(d, cv, t, ev, p=6, pf=false)
Compare a computed test value with an known good result.
module map_validate_start(db, verbose=false)
Test data structure db and output the start of test to the test log.
function table_validate_get_v3(db, id)
Return the test argument value 3.
validation_skip
Value signature assignment for log-value results table to skip a test.
function map_validate_get_v2(db, id)
Return the test argument value 2.
function table_validate_get_ids(db)
Return a list of test identifiers in db.
module validate_log(t)
Output text t to the test log.
function table_validate_init(tr, gr)
Create data structure for related table validation functions.
function table_validate_get_v2(db, id)
Return the test argument value 2.
function table_validate_get_ev(db, fn, id)
Return the expected value.
function map_validate_get_td(db, id)
Return the test description.
function map_validate_get_ev(db, id)
Return the expected value.
module table_validate(db, id, fn, argc, fr, t="equals", p=6)
Validate and log a test function return value against its expected value.
module map_validate(db, id, argc, fr, t="equals", p=6)
Validate and log a test function return value against its expected value.
function map_validate_get_v3(db, id)
Return the test argument value 3.
function table_validate_fmt(id, td, v1, v2, v3)
Encode an entry for test table.
function map_validate_get_ids(db)
Return a list of test identifiers in db.
function map_validate_get_v1(db, id)
Return the test argument value 1.
function table_validate_get_v1(db, id)
Return the test argument value 1.
function table_validate_get_td(db, id)
Return the test description.
function third(v)
Return the third element of an iterable value.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function almost_eq(v1, v2, p=6)
Test if all elements of two iterable values are sufficiently equal.
function merge_p(v, j=true)
Parallel-merge the iterable elements of a list.
function map_get_value(m, k)
Get the map value associated with a key.
function map_get_keys(m)
Get a list of all map keys.
module map_check(m, verbose=false)
Perform basic format checks on a map and output errors to console.
Definition: map.scad:788
module table_check(r, c, verbose=false)
Perform basic format checks on a table and output errors to console.
Definition: table.scad:839
function table_get_row_ids(r)
Form a list of all table row identifiers.
function table_get_value(r, c, ri, ci)
Get the table cell value for a specified row and column identifier.