@jdeighan/coffee-utils 4.1.9 → 4.1.13

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "4.1.9",
4
+ "version": "4.1.13",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "scripts": {
22
22
  "build": "cls && rm -f ./src/*.js && coffee -c ./src",
23
- "pretest": "npm run build && rm -f ./test/*.js && rm -f ./test/*.coffee && cielo -fq ./test",
23
+ "old_pretest": "npm run build && rm -f ./test/*.js && rm -f ./test/*.coffee && cielo -fq ./test",
24
+ "pretest": "cls && coffee -c .",
24
25
  "test": "ava ./test/*.test.js",
25
26
  "prefinaltest": "npm run pretest",
26
27
  "finaltest": "cross-env FINALTEST=yes ava ./test/*.test.js"
@@ -176,6 +176,10 @@ export class UnitTester
176
176
  assert isInteger(lineNum),
177
177
  "UnitTester.test(): arg 1 must be an integer"
178
178
 
179
+ if process.env.TEST_LINE_NUMBER
180
+ if Math.abs(lineNum) != parseInt(process.env.TEST_LINE_NUMBER)
181
+ return
182
+
179
183
  @initialize()
180
184
  @lineNum = lineNum # set an object property
181
185
 
@@ -196,7 +200,7 @@ export class UnitTester
196
200
  got = @normalize(got)
197
201
  catch err
198
202
  errMsg = err.message || 'UNKNOWN ERROR'
199
- log "got ERROR: #{errMsg}"
203
+ log "got ERROR in unit test: #{errMsg}"
200
204
 
201
205
  expected = @transformExpected(expected)
202
206
  if isString(expected)
package/src/UnitTester.js CHANGED
@@ -186,6 +186,11 @@ export var UnitTester = class UnitTester {
186
186
  test(lineNum, input, expected) {
187
187
  var err, errMsg, got, whichTest;
188
188
  assert(isInteger(lineNum), "UnitTester.test(): arg 1 must be an integer");
189
+ if (process.env.TEST_LINE_NUMBER) {
190
+ if (Math.abs(lineNum) !== parseInt(process.env.TEST_LINE_NUMBER)) {
191
+ return;
192
+ }
193
+ }
189
194
  this.initialize();
190
195
  this.lineNum = lineNum; // set an object property
191
196
  if ((lineNum < 0) && process.env.FINALTEST) {
@@ -207,7 +212,7 @@ export var UnitTester = class UnitTester {
207
212
  } catch (error1) {
208
213
  err = error1;
209
214
  errMsg = err.message || 'UNKNOWN ERROR';
210
- log(`got ERROR: ${errMsg}`);
215
+ log(`got ERROR in unit test: ${errMsg}`);
211
216
  }
212
217
  expected = this.transformExpected(expected);
213
218
  if (isString(expected)) {
@@ -86,7 +86,7 @@ export joinBlocks = (lBlocks...) ->
86
86
 
87
87
  lNonEmptyBlocks = []
88
88
  for block in lBlocks
89
- assert isString(block), "joinBlocks(): block is not a string"
89
+ assert isString(block), "joinBlocks(): #{block} is not a string"
90
90
  if nonEmpty(block)
91
91
  lNonEmptyBlocks.push block
92
92
  return lNonEmptyBlocks.join('\n')
@@ -110,7 +110,7 @@ export var joinBlocks = function(...lBlocks) {
110
110
  lNonEmptyBlocks = [];
111
111
  for (i = 0, len1 = lBlocks.length; i < len1; i++) {
112
112
  block = lBlocks[i];
113
- assert(isString(block), "joinBlocks(): block is not a string");
113
+ assert(isString(block), `joinBlocks(): ${block} is not a string`);
114
114
  if (nonEmpty(block)) {
115
115
  lNonEmptyBlocks.push(block);
116
116
  }
@@ -34,7 +34,7 @@ export assert = (cond, msg) ->
34
34
  export croak = (err, label, obj) ->
35
35
 
36
36
  message = if (typeof err == 'object') then err.message else err
37
- log "ERROR: #{message}"
37
+ log "ERROR (croak): #{message}"
38
38
  log label, obj
39
39
  if (typeof err == 'object')
40
40
  throw err
@@ -37,7 +37,7 @@ export var assert = function(cond, msg) {
37
37
  export var croak = function(err, label, obj) {
38
38
  var message;
39
39
  message = (typeof err === 'object') ? err.message : err;
40
- log(`ERROR: ${message}`);
40
+ log(`ERROR (croak): ${message}`);
41
41
  log(label, obj);
42
42
  if (typeof err === 'object') {
43
43
  throw err;