Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nichoth committed Feb 29, 2024
1 parent 42a3b4a commit dc297b0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion fast-deep-equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@



module.exports = function equal(a, b) {
export function equal(a, b) {
if (a === b) return true;

if (a && b && typeof a == 'object' && typeof b == 'object') {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// @ts-check

const deepEqual = require('./fast-deep-equal')
import { equal as deepEqual } from './fast-deep-equal.js'

const NEW_LINE_REGEX = /\n/g
const OBJ_TO_STRING = Object.prototype.toString
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"version": "0.8.7",
"description": "Smallest test library",
"main": "dist/index.js",
"type": "module",
"scripts": {
"tsc": "npr tsc -p jsconfig.json --maxNodeModuleJsDepth 0",
"//tsc": "npr tsc -p jsconfig.json --maxNodeModuleJsDepth 0",
"build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-cjs && npm run build-esm",
"build-cjs": "esbuild ./index.js --format=cjs --keep-names --outdir=./dist --out-extension:.js=.cjs --sourcemap=inline",
"build-esm": "cp ./index.js ./dist",
"test": "npm run tsc && node test/harness.js && node test/index.js && npr type-coverage",
"//test": "npm run build && node test/index.js && npr type-coverage",
"test": "npm run build && cd test && node index.js && cd .. && npr type-coverage",
"postversion": "git push --follow-tags && npm publish",
"vendor": "cp node_modules/fast-deep-equal/index.js ./fast-deep-equal.js; sed -i '1s;^;// Copied from fast-deep-equal@3.1.1.\\n// @ts-nocheck\\n;' fast-deep-equal.js",
"version": "auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md",
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// @ts-check

require('./unit/smoke')
require('./zora/test-cases')
import './unit/smoke.js'
import './zora/test-cases.js'
9 changes: 6 additions & 3 deletions test/unit/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

// @ts-check

const test = require('@pre-bundled/tape')
// const test = require('@pre-bundled/tape')
import test from '@pre-bundled/tape'
import { TestRunner } from '../../index.js'
import { collect, trimPrefix } from '../util.js'

const { TestRunner } = require('../../index.js')
const { collect, trimPrefix } = require('../util.js')
// const { TestRunner } = require('../../index.js')
// const { collect, trimPrefix } = require('../util.js')

test('tapzero outputs TAP', (assert) => {
const h = new TestRunner(collect(verify))
Expand Down
15 changes: 8 additions & 7 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

// @ts-check

const path = require('path')
// const path = require('path')
import path from 'path'

const NUMBER_LINE = /^1\.\.\d+$/
const FAIL_LINE = /^# fail[ ]{2}\d+$/

exports.collect = collect
exports.strip = strip
exports.trimPrefix = trimPrefix
// exports.collect = collect
// exports.strip = strip
// exports.trimPrefix = trimPrefix

/**
* @param {(a: string) => void} fn
* @returns {(line: string) => void}
*/
function collect (fn) {
export function collect (fn) {
/** @type {string[]} */
const total = []
let almostFinished = false
Expand Down Expand Up @@ -43,7 +44,7 @@ function collect (fn) {
* @param {string} line
* @returns {string}
*/
function strip (line) {
export function strip (line) {
const withoutTestDir = line.replace(
new RegExp(__dirname, 'g'), '$TEST'
)
Expand Down Expand Up @@ -84,7 +85,7 @@ function strip (line) {
* @param {TemplateStringsArray} text
* @returns {string}
*/
function trimPrefix (text) {
export function trimPrefix (text) {
const lines = text[0].split('\n')
let commonPrefix = Infinity
for (const line of lines) {
Expand Down

0 comments on commit dc297b0

Please sign in to comment.