-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to filter tests #212
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a6bcc83
Added status info to specifications
SebastianZ 1547e0f
Added filter for specifications
SebastianZ f8aa0f4
Corrected test duration output
SebastianZ c1b83bd
Only set output info once
SebastianZ ebb313a
Added a filter for experimental specifications
SebastianZ 2762835
Replaced optional chaining operator by legacy JS
SebastianZ 562fbba
Replaced let by var
SebastianZ ec86c3a
Replaced missed lets by vars
SebastianZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,6 +394,73 @@ function passclass(info) { | |
return classes[index]; | ||
} | ||
|
||
function resetOutput() { | ||
mainScore = new Score(); | ||
|
||
// Output current score | ||
ele('score').textContent = ''; | ||
ele('passedTests').textContent = ''; | ||
ele('totalTests').textContent = ''; | ||
ele('total').textContent = ''; | ||
ele('specsTested').textContent = ''; | ||
ele('all').textContent = ''; | ||
|
||
// Display time taken | ||
ele('timeTaken').textContent = ''; | ||
} | ||
|
||
function runTests(filter = '') { | ||
let specs = []; | ||
let timeBefore = +new Date; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
var removedWords = / *(?:\([^)]*\)|:.*|\b(?:CSS|Module)\b)( *)/g; | ||
|
||
for (var spec in Specs) { | ||
// Filter list of specifications | ||
if (filter === 'stable' && Specs[spec].status && Specs[spec].status.stability !== 'stable') { | ||
continue; | ||
} else if (filter === 'experimental' && Specs[spec].status && Specs[spec].status.stability === 'stable') { | ||
continue; | ||
} else if (Number(filter) > 0) { | ||
if (!Specs[spec].status || Specs[spec].status['first-snapshot'] === undefined) { | ||
continue; | ||
} | ||
|
||
const snapshot = Number(filter); | ||
if ( | ||
Specs[spec].status['first-snapshot'] > snapshot || | ||
(Specs[spec].status && Specs[spec].status['last-snapshot'] < snapshot) | ||
) { | ||
continue; | ||
} | ||
} | ||
|
||
specs.push({ | ||
id: spec, | ||
// Shorten the title by removing parentheticals, | ||
// subheadings, CSS and Module words | ||
title: Specs[spec].title.replace(removedWords, "$1").trim(), | ||
tests: Specs[spec] | ||
}); | ||
} | ||
|
||
specs.sort(function (a, b) { | ||
return a.title.localeCompare(b.title); | ||
}); | ||
|
||
// Run tests | ||
specs.forEach(spec => new Test(spec)); | ||
|
||
// Output score | ||
ele('score').textContent = mainScore + ''; | ||
ele('passedTests').textContent = ~~mainScore.passedTests; | ||
ele('totalTests').textContent = mainScore.totalTests; | ||
ele('total').textContent = mainScore.total; | ||
|
||
// Display time taken | ||
ele('timeTaken').textContent = +new Date - timeBefore + 'ms'; | ||
} | ||
|
||
Array.prototype.and = function (arr2, separator) { | ||
separator = separator || ' '; | ||
|
||
|
@@ -440,57 +507,6 @@ Array.prototype.times = function (min, max, separator) { | |
}; | ||
|
||
onload = function () { | ||
var timeBefore = +new Date, | ||
duration = 0, | ||
specs = []; | ||
|
||
var removedWords = / *(?:\([^)]*\)|:.*|\b(?:CSS|Module)\b)( *)/g; | ||
|
||
for (var spec in Specs) { | ||
specs.push({ | ||
id: spec, | ||
// Shorten the title by removing parentheticals, | ||
// subheadings, CSS and Module words | ||
title: Specs[spec].title.replace(removedWords, "$1").trim(), | ||
tests: Specs[spec] | ||
}); | ||
} | ||
|
||
specs.sort(function (a, b) { | ||
return a.title.localeCompare(b.title); | ||
}); | ||
|
||
|
||
(function () { | ||
if (specs.length) { | ||
// Get spec id | ||
var spec = specs.shift(); | ||
|
||
// Run tests | ||
var test = new Test(spec); | ||
|
||
// Count test duration | ||
duration += +new Date - timeBefore; | ||
timeBefore = +new Date; | ||
|
||
// Output current score | ||
ele('score').textContent = mainScore + ''; | ||
ele('passedTests').textContent = ~~mainScore.passedTests; | ||
ele('totalTests').textContent = mainScore.totalTests; | ||
ele('total').textContent = mainScore.total; | ||
|
||
// Schedule next test | ||
setTimeout(arguments.callee, 50) | ||
} | ||
else { | ||
// Done! | ||
|
||
// Display time taken | ||
ele('timeTaken').textContent = +new Date - timeBefore + 'ms'; | ||
} | ||
})(); | ||
|
||
|
||
|
||
|
||
ele('filter').value = localStorage.getItem('filter') || ''; | ||
runTests(localStorage.getItem('filter') || ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(function() { | ||
ele('filter').addEventListener('change', evt => { | ||
PolariTOON marked this conversation as resolved.
Show resolved
Hide resolved
|
||
localStorage.setItem('filter', evt.target.value); | ||
resetOutput(); | ||
runTests(evt.target.value); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you replaced some
var
keywords bylet
.Do we want to embrace ES6-style javascript now? or still being somehow compatible with old browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE isn't really dead yet. For me, it would be necessary to wait until it's definitely dead (removal of Windows). I let you decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to caniuse.com, IE has (partial) support for
let
. The biggest percentage of a non-supporting browser is Opera Mini with ~1%. And the overall support is at ~95%, which seems pretty stable to me.Personally, I prefer to use ES6+ features as long as there is good browser support for them. If you two believe we should strive for full backwards compatibility, I could change it back to
var
.Though I have to admit, I never tried to call the site in a very old browser so far. I assume there are other pieces of code that might be unsupported in older browsers.
Having said that, I am also planning to push #57 forward which requires a good browser coverage. So maybe that requires the JS part to be backwards compatible.
Sebastian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, IE is removed in Windows 11 and finally will be gone in June this year, though it will surely still take many years until nobody uses IE anymore.
According to statcounter IE still has a market share of 0.46%.
Sebastian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there's a mixture of
var
andlet
after that patch, I decided to roll back tovar
again for now.I'll file a follow-up issue on refactoring the code base, instead.
Sebastian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've filed #216 now to discuss whether and which ES6+ features we want to use. Feel free to comment there!
Sebastian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this line also be reverted to
var
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank's for the hint!