Skip to content

Commit

Permalink
Docs: Publish a copy of the q4000 benchmark to qunitjs.com
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Jan 24, 2025
1 parent 0ecf13f commit 65d0e6f
Show file tree
Hide file tree
Showing 3 changed files with 25,359 additions and 23 deletions.
61 changes: 39 additions & 22 deletions build/q4000-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,45 @@
const fs = require('fs');
const path = require('path');

const q3000 = require('../test/benchmark/q4000.json');
const q4000 = require('../test/benchmark/q4000.json');

// Deal with indentation etc later via eslint --fix (or `npm run lint-fix`).
const formatTest = (name) => `QUnit.test(${JSON.stringify(name)}, function (assert) {
assert.true(true);
assert.true(true);
});`;

function formatMembers (members) {
return members.map(member => {
if (typeof member === 'string') {
return formatTest(member);
} else {
const tests = formatMembers(member.members);
return `QUnit.module(${JSON.stringify(member.name)}, function () {
${tests}
});`;
}
}).join('\n\n');
}

{
const FILE = 'demos/q4000-qunit.js';
const fullPath = path.join(__dirname, '..', FILE);

fs.writeFileSync(fullPath, formatMembers(q4000));
console.log('Written to ' + FILE);
}

{
const file = 'demos/q4000-qunit.js';

// Deal with indentation etc later via eslint --fix (or `npm run lint-fix`).
const formatTest = (name) => `QUnit.test(${JSON.stringify(name)}, function (assert) {
assert.true(true);
assert.true(true);
});`;
const formatMembers = (members) => {
return members.map(member => {
if (typeof member === 'string') {
return formatTest(member);
} else {
const tests = formatMembers(member.members);
return `QUnit.module(${JSON.stringify(member.name)}, function () {
${tests}
});`;
}
}).join('\n\n');
};
fs.writeFileSync(path.join(__dirname, '..', file), formatMembers(q3000));
console.log('Written to ' + file);
const FILE = 'docs/resources/q4000.html';
const fullPath = path.join(__dirname, '..', FILE);

const contents = fs.readFileSync(fullPath, 'utf8').replace(
/<script>[^<]*?<\/script>/,
`<script>\n${formatMembers(q4000)}\n</script>`
);

fs.writeFileSync(fullPath, contents);

console.log('Written to ' + FILE);
}
3 changes: 2 additions & 1 deletion build/site-set-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const files = {
'docs/browser.md': [...cdnLinks],
'docs/resources/example-add.html': [...cdnLinks],
'docs/resources/example-fail.html': [...cdnLinks],
'docs/resources/example-index.html': [...cdnLinks]
'docs/resources/example-index.html': [...cdnLinks],
'docs/resources/q4000.html': [...cdnLinks]
};

try {
Expand Down
Loading

0 comments on commit 65d0e6f

Please sign in to comment.