Created
October 23, 2013 22:06
-
-
Save dbrock/7127620 to your computer and use it in GitHub Desktop.
Example of the limits of the Bats preprocessor.
This file contains hidden or 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
# -*- sh -*- | |
@test "empty input" { diff <<'^D' - <(bin/html </dev/null); } | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
</body> | |
</html> | |
^D |
Thanks. Good to know that it only touches the first line. And the function redirection is a great workaround to avoid having to put the brace after the heredoc!
I’ll dig in to the parser to see how it works. Lately I’ve been playing around with the function declaration syntax a lot and having a lot of fun with it, using other kinds of compound commands for function bodies instead of the usual { ... }
, etc. I kind of like how flexible it is!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, it could be smarter about single-line test declarations. The preprocessor doesn't touch anything past the first line though, so this should work: