示例工程 06-generics

06-generics/03-defaults/main.test.mjs

javascript · 0.4 KB

运行:06 · defaults

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBox, run } from './dist/main.js';
 
test('默认类型参数不影响运行时结构', () => {
  const out = [];
  const ret = run((msg) => out.push(msg));
  assert.deepEqual(ret, ['text', '42', '#7']);
  assert.deepEqual(out, ret);
  assert.deepEqual(makeBox('a'), { value: 'a' });
});