Comparing version
const dequal = require('dequal'); | ||
const { compare, direct, lines } = require('../diff'); | ||
const { compare, direct, lines } = require('uvu/diff'); | ||
@@ -44,2 +44,6 @@ function dedent(str) { | ||
function unreachable(msg) { | ||
assert(false, true, false, 'unreachable', false, 'Expected not to be reached!', msg); | ||
} | ||
function type(val, exp, msg) { | ||
@@ -88,3 +92,3 @@ let tmp = typeof val; | ||
function not(val, msg, oper = 'not') { | ||
function not(val, msg) { | ||
assert(!val, true, false, 'not', false, 'Expected value to be falsey', msg); | ||
@@ -151,2 +155,3 @@ } | ||
exports.throws = throws; | ||
exports.type = type; | ||
exports.type = type; | ||
exports.unreachable = unreachable; |
@@ -46,5 +46,5 @@ #!/usr/bin/env node | ||
global.UVU_DEFER = 1; | ||
globalThis.UVU_DEFER = 1; | ||
suites.forEach((x, idx) => { | ||
global.UVU_INDEX = idx; | ||
globalThis.UVU_INDEX = idx; | ||
QUEUE.push([x.name]); | ||
@@ -51,0 +51,0 @@ require(x.file); // auto-add to queue |
@@ -0,3 +1,3 @@ | ||
const kleur = require('kleur'); | ||
const diff = require('diff'); | ||
const kleur = require('kleur'); | ||
@@ -55,3 +55,3 @@ const colors = { | ||
let arr = diff.diffChars(input, expect); | ||
let i=0, output='', tmp = arr[i]; | ||
let i=0, output='', tmp; | ||
@@ -64,2 +64,4 @@ let l1 = input.length; | ||
tmp = arr[i]; | ||
// TODO: debug this | ||
@@ -66,0 +68,0 @@ if (tmp.removed) { |
const kleur = require('kleur'); | ||
const { compare } = require('../diff'); | ||
const { compare } = require('uvu/diff'); | ||
let isCLI = false, isNode = false; | ||
let write = x => process.stdout.write(x); // TODO(browser) | ||
let hrtime = (now = Date.now()) => () => (Date.now() - now).toFixed(2) + 'ms'; | ||
let write = console.log; | ||
@@ -14,5 +14,14 @@ const into = (ctx, key) => (name, handler) => ctx[key].push({ name, handler }); | ||
if (isNode = typeof process !== 'undefined') { | ||
// globalThis polyfill; Node < 12 | ||
if (typeof globalThis !== 'object') { | ||
Object.defineProperty(global, 'globalThis', { | ||
get: function () { return this } | ||
}); | ||
} | ||
let rgx = /(\.bin[\\+\/]uvu$|uvu[\\+\/]bin\.js)/i; | ||
isCLI = process.argv.some(x => rgx.test(x)); | ||
// attach node-specific utils | ||
write = x => process.stdout.write(x); | ||
hrtime = (now = process.hrtime()) => () => milli(process.hrtime(now)); | ||
@@ -89,3 +98,3 @@ } | ||
let run = runner.bind(0, copy, name); | ||
QUEUE[global.UVU_INDEX || 0].push(run); | ||
QUEUE[globalThis.UVU_INDEX || 0].push(run); | ||
}; | ||
@@ -101,3 +110,3 @@ return test; | ||
async function exec(bail) { | ||
export async function exec(bail) { | ||
let timer = hrtime(); | ||
@@ -134,4 +143,3 @@ let done=0, total=0, code=0; | ||
exports.QUEUE = QUEUE; | ||
exports.exec = exec; | ||
exports.suite = suite; | ||
exports.test = test; |
@@ -34,2 +34,3 @@ declare namespace uvu { | ||
export function not(actual: any, msg?: Message): void; | ||
export function unreachable(msg?: Message): void; | ||
@@ -36,0 +37,0 @@ export namespace is { |
{ | ||
"name": "uvu", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"module": "dist/index.mjs", | ||
@@ -42,3 +42,3 @@ "main": "dist/index.js", | ||
"diff": "^4.0.2", | ||
"kleur": "^3.0.0", | ||
"kleur": "^4.0.0", | ||
"sade": "^1.7.3", | ||
@@ -45,0 +45,0 @@ "totalist": "^1.0.1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30434
2.26%781
3.03%+ Added
- Removed
Updated