-
Notifications
You must be signed in to change notification settings - Fork 23
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
Prettify the stdlib testing framework #542
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
844b6ab
Make the Effekt testing suite a little prettier
jiribenes 851f5df
Try to fix tests, add a version without bench
jiribenes c18ed9f
Reduce the 'Duration' submodule
jiribenes 45aafd3
Fix formatting, rename 'dimWhenZeroElse' (sigh)
jiribenes f54bcad
Try importing performance explicitly in NodeJS
jiribenes 671d9d9
Shuffle test results around
jiribenes 761d01d
Don't test the test library on LLVM and MLton
jiribenes 936ca8f
Add a few more comments in 'test'
jiribenes b4dadfa
Rename parameters of formatting functions
jiribenes 63252ed
Add even more comments
jiribenes 51d7849
Re-add forgotten explicit namespace
jiribenes 618cd74
Tests should now be supported on LLVM again
jiribenes 2da8f9d
Explicit import via node, modify comment to reflect NodeJS16.x and newer
jiribenes 71676ab
Separate out string/tty, make bench slightly more typesafe
jiribenes 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
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
Arithmetic | ||
✓ addition | ||
✕ faulty addition | ||
2 + 2 should be 4! | ||
✓ multiplication | ||
|
||
2 pass | ||
1 fail | ||
3 tests total |
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
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,8 @@ | ||
Test test suite | ||
✓ Test test assertTrue | ||
✓ Test test assertFalse | ||
✓ Test test assert | ||
|
||
3 pass | ||
0 fail | ||
3 tests total |
3 changes: 2 additions & 1 deletion
3
examples/stdlib/test/test.effekt → examples/stdlib/test/pass.effekt
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
This file was deleted.
Oops, something went wrong.
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
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
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,66 @@ | ||
module string/tty | ||
|
||
// ANSI escape codes | ||
namespace ANSI { | ||
val CSI = "\u001b[" | ||
|
||
def escape(s: String) = CSI ++ s ++ "m" | ||
|
||
val BLACK = escape("30") | ||
val RED = escape("31") | ||
val GREEN = escape("32") | ||
val YELLOW = escape("33") | ||
val BLUE = escape("34") | ||
val MAGENTA = escape("35") | ||
val CYAN = escape("36") | ||
val WHITE = escape("37") | ||
|
||
val BG_BLACK = escape("40") | ||
val BG_RED = escape("41") | ||
val BG_GREEN = escape("42") | ||
val BG_YELLOW = escape("43") | ||
val BG_BLUE = escape("44") | ||
val BG_MAGENTA = escape("45") | ||
val BG_CYAN = escape("46") | ||
val BG_WHITE = escape("47") | ||
|
||
val RESET = escape("0") | ||
|
||
val BOLD = escape("1") | ||
val FAINT = escape("2") | ||
val ITALIC = escape("3") | ||
val UNDERLINE = escape("4") | ||
val BLINK = escape("5") | ||
val REVERSE = escape("7") | ||
val CROSSOUT = escape("9") | ||
val OVERLINE = escape("53") | ||
} | ||
|
||
def red(text: String) = Formatted::colored(text, ANSI::RED) | ||
def green(text: String) = Formatted::colored(text, ANSI::GREEN) | ||
def dim(text: String) = Formatted::colored(text, ANSI::FAINT) | ||
def bold(text: String) = Formatted::colored(text, ANSI::BOLD) | ||
|
||
interface Formatted { | ||
def supportsEscape(escape: String): Bool | ||
} | ||
|
||
namespace Formatted { | ||
/// Run given block of code, allowing all formatting | ||
def formatting[R] { prog : => R / Formatted }: R = | ||
try { prog() } with Formatted { | ||
def supportsEscape(escape: String) = resume(true) | ||
} | ||
|
||
/// Run given block of code, ignoring all formatting | ||
def noFormatting[R] { prog : => R / Formatted }: R = | ||
try { prog() } with Formatted { | ||
def supportsEscape(escape: String) = resume(false) | ||
} | ||
|
||
def tryEmit(escape: String): String / Formatted = | ||
if (do supportsEscape(escape)) escape else "" | ||
|
||
def colored(text: String, colorEscape: String): String / Formatted = | ||
tryEmit(colorEscape) ++ text ++ tryEmit(ANSI::RESET) | ||
} |
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.
This would need #544, but we can fix that later, I'm fine with MLton support being rather second-class. :)