apjanke / octave-testify

New BIST (Built-In Self Test) functions for GNU Octave
GNU General Public License v3.0
4 stars 2 forks source link

Improve "-verbose" output #74

Open apjanke opened 5 years ago

apjanke commented 5 years ago

Octave's test looks like this:

***** test
 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso,
                                       "zmin", "b", "verbose");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
***** test
 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso,
                                       "below", "v", "zmax");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
***** error isocaps ()
***** error isocaps (1,2,3,4,5,6,7,8,9)
***** error <parameter 'foo' not supported> isocaps (val, iso, "foo")
***** error <incorrect number of input arguments> isocaps (x, val, iso)
***** error <incorrect number of input arguments> isocaps (xx, yy, zz, val, iso, 5)
***** error <V must be a non-singleton 3-dimensional matrix>
 v2 = reshape (1:6*8, [6 8]);
 fvc = isocaps (v2, iso);
***** error <V must be a non-singleton 3-dimensional matrix>
 v3 = reshape (1:6*8, [6 1 8]);
 fvc = isocaps (v3, iso);
***** error <X must match the size of V>
 x = 1:2:24;
 fvc = isocaps (x, y, z, val, iso);

My test2 looks like this:

*****  testify.internal.BistBlock: test (index=13)
  is_test=1  is_xtest=0
  bug_id=  fixed_bug=
Code:

 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso, "xmin");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
  -> success=1, msg=
*****  testify.internal.BistBlock: test (index=14)
  is_test=1  is_xtest=0
  bug_id=  fixed_bug=
Code:

 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso, "verbose");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
  -> success=1, msg=
*****  testify.internal.BistBlock: test (index=15)
  is_test=1  is_xtest=0
  bug_id=  fixed_bug=
Code:

 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso, "xmax", "above");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
  -> success=1, msg=
*****  testify.internal.BistBlock: test (index=16)
  is_test=1  is_xtest=0
  bug_id=  fixed_bug=
Code:

 [faces, vertices, fvcdata] = isocaps (x, y, z, val, iso,
                                       "zmin", "b", "verbose");
 assert (columns (faces), 3);
 assert (columns (vertices), 3);
 assert (columns (fvcdata), 1);
 assert (rows (vertices), rows (fvcdata));
  -> success=1, msg=

Improve its readability.

apjanke commented 5 years ago

Improved in https://github.com/apjanke/octave-testify/commit/7ee28d7809eab0ede3950768a8e6542808d9697c and https://github.com/apjanke/octave-testify/commit/1c1086e4557e30427a58b8b0263b2f1d48ab12a1.

Now it looks like this:

>> test2 isosurface -verbose

>>>>> /Applications/Octave-5.1.0.app/Contents/Resources/usr/Cellar/octave-octave-app@5.1.0/5.1.0/share/octave/5.1.0/m/plot/draw/isosurface.m
*****  test block 1: demo

 clf;
 [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2);
 v = x.^2 + y.^2 + z.^2;
 isosurface (x, y, z, v, 1);
 axis equal;
 title ("isosurface() of a sphere");
--> success=1, msg=----- demo skipped

*****  test block 2: demo

 clf;
 [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2);
 v = x.^2 + y.^2 + z.^2;
 isosurface (x, y, z, v, 3);
 isosurface (x, y, z, v, 5);
 axis equal;
 title ("isosurface() of two nested spheres");
--> success=1, msg=----- demo skipped
[...]
*****  test block 23: error
  is_test=1  is_xtest=0
  error_id=''
  pattern=/V must be a non-singleton 3-dimensional matrix/
Code:
 v = reshape(1:6*8, [6 1 8]); fvc = isosurface (v, iso);
--> success=1, msg=
*****  test block 24: error
  is_test=1  is_xtest=0
  error_id=''
  pattern=/X must match the size of V/
Code:
 x = 1:2:24;
 fvc = isosurface (x, y, z, val, iso);
--> success=1, msg=
*****  test block 25: error
  is_test=1  is_xtest=0
  error_id=''
  pattern=/Y must match the size of V/
Code:
 y = -14:6:11;
 fvc = isosurface (x, y, z, val, iso);
--> success=0, msg=!!!!! Incorrect error raised: expected error message matching /Y must match the size of V/, but got 'isosurface: X must match thesize of V'
----- Failure details: block 25 -----
*****  test block 25: error
  is_test=1  is_xtest=0
  error_id=''
  pattern=/Y must match the size of V/
Code:
 y = -14:6:11;
 fvc = isosurface (x, y, z, val, iso);
--> success=0, msg=!!!!! Incorrect error raised: expected error message matching /Y must match the size of V/, but got 'isosurface: X must match thesize of V'
Aborted test run due to test failure.
PASSES 20 out of 21 tests

Next up, I think I need to compact the property display for BistBlock.

apjanke commented 5 years ago

More improvement in https://github.com/apjanke/octave-testify/commit/9d12856767ff184f07c28423167d4a34bb4badc3.

Now it's like:

>> test2 isosurface -verbose

>>>>> /Applications/Octave-5.1.0.app/Contents/Resources/usr/Cellar/octave-octave-app@5.1.0/5.1.0/share/octave/5.1.0/m/plot/draw/isosurface.m
*****  test block 1: demo

 clf;
 [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2);
 v = x.^2 + y.^2 + z.^2;
 isosurface (x, y, z, v, 1);
 axis equal;
 title ("isosurface() of a sphere");
--> success=1, msg=----- demo skipped
[...]
*****  test block 15: test
  is_test=1 is_xtest=0
Code:
 fv = isosurface (val, iso, "verbose");
 assert (isfield (fv, "vertices"), true);
 assert (isfield (fv, "faces"), true);
 assert (size (fv.vertices), [11 3]);
 assert (size (fv.faces), [10 3]);
--> success=1, msg=
*****  test block 16: test
  is_test=1 is_xtest=0
Code:
 fvc = isosurface (xx, yy, zz, val, iso, yy, "v", "noshare");
 assert (isfield (fvc, "vertices"), true);
 assert (isfield (fvc, "faces"), true);
 assert (isfield (fvc, "facevertexcdata"), true);
 assert (size (fvc.vertices), [20 3]);
 assert (size (fvc.faces), [10 3]);
 assert (size (fvc.facevertexcdata), [20 1]);
--> success=1, msg=
*****  test block 17: test
  is_test=1 is_xtest=0
Code:
 fvc = isosurface (xx, yy, zz, val, yy, "n", "v");
 assert (isfield (fvc, "vertices"), true);
 assert (isfield (fvc, "faces"), true);
 assert (isfield (fvc, "facevertexcdata"), true);
 assert (size (fvc.vertices), [7 3]);
 assert (size (fvc.faces), [3 3]);
 assert (size (fvc.facevertexcdata), [7 1]);
--> success=1, msg=
*****  test block 18: error /./
  is_test=1 is_xtest=0
Code:
 isosurface ()
--> success=1, msg=
*****  test block 19: error /./
  is_test=1 is_xtest=0
Code:
 isosurface (1,2,3,4,5,6,7,8,9)
--> success=1, msg=
*****  test block 20: error /parameter 'foobar' not supported/
  is_test=1 is_xtest=0
Code:
 fvc = isosurface (val, iso, "foobar");
--> success=1, msg=
*****  test block 21: error /incorrect number of input arguments/
  is_test=1 is_xtest=0
Code:
 fvc = isosurface (xx, yy, zz, val, iso, yy, 5);
--> success=1, msg=
*****  test block 22: error /V must be a non-singleton 3-dimensional matrix/
  is_test=1 is_xtest=0
Code:
 v = reshape (1:6*8, [6 8]);
 fvc = isosurface (v, iso);
--> success=1, msg=
*****  test block 23: error /V must be a non-singleton 3-dimensional matrix/
  is_test=1 is_xtest=0
Code:
 v = reshape(1:6*8, [6 1 8]); fvc = isosurface (v, iso);
--> success=1, msg=
*****  test block 24: error /X must match the size of V/
  is_test=1 is_xtest=0
Code:
 x = 1:2:24;
 fvc = isosurface (x, y, z, val, iso);
--> success=1, msg=
*****  test block 25: error /Y must match the size of V/
  is_test=1 is_xtest=0
Code:
 y = -14:6:11;
 fvc = isosurface (x, y, z, val, iso);
--> success=0, msg=!!!!! Incorrect error raised: expected error message matching /Y must match the size of V/, but got 'isosurface: X must match thesize of V'
----- Failure details: block 25 -----
*****  test block 25: error /Y must match the size of V/
  is_test=1 is_xtest=0
Code:
 y = -14:6:11;
 fvc = isosurface (x, y, z, val, iso);
--> success=0, msg=!!!!! Incorrect error raised: expected error message matching /Y must match the size of V/, but got 'isosurface: X must match thesize of V'
Aborted test run due to test failure.
PASSES 20 out of 21 tests
apjanke commented 5 years ago

One more tiny tweak in https://github.com/apjanke/octave-testify/commit/67d5a85608815858917ad8812894ae5b1d9a075a: just the spacing between the "signal" symbols and the start of the text.