Skip to content

Commit

Permalink
Merge pull request #25 from e-bigmoon/hamlet-testcases
Browse files Browse the repository at this point in the history
Hamlet testcases  -- interpolation and conditional
  • Loading branch information
waddlaw authored Jun 19, 2021
2 parents c167c83 + 3896107 commit 8c72884
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

### Changed

- Fix existing test cases for hamlet and add Hamlet testcases (interpolation and conditional) [#25](https://github.com/e-bigmoon/vscode-language-yesod/pull/25) @isao-takejib
- Changed to also use Haskell syntax files for testing [#38](https://github.com/e-bigmoon/vscode-language-yesod/pull/38) @isao-takejib
- Add a badge for github actions [#36](https://github.com/e-bigmoon/vscode-language-yesod/pull/36) @isao-takejib
- Fixing test cases [#35](https://github.com/e-bigmoon/vscode-language-yesod/pull/35) @isao-takejib
Expand Down
13 changes: 9 additions & 4 deletions syntaxes/hamlet.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@
"keyword": {
"patterns": [
{
"match": "\\$(else|nothing|doctype|newline)\\s+",
"name": "keyword.control.hamlet"
"match": "(\\$(else|nothing|doctype|newline))\\s+",
"captures": {
"1": {
"name": "keyword.control.hamlet"
}
},
"name": "meta.interpolation.hamlet"
},
{
"begin": "\\$(if|elseif|maybe|forall|case|of|with)\\s+",
"begin": "(\\$(if|elseif|maybe|forall|case|of|with))\\s+",
"beginCaptures": {
"0": {
"1": {
"name": "keyword.control.hamlet"
}
},
Expand Down
24 changes: 24 additions & 0 deletions test/tests/hamlet/conditionals.hamlet
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$# SYNTAX TEST "source.yesod.hamlet" "conditionals"
$if isAdmin
$# <--- meta.interpolation.hamlet keyword.control.hamlet
$# ^ - keyword.control.hamlet
$# ^^^^^^^ meta.interpolation.hamlet source.haskell.embedded
<p>Welcome to the admin section.
$# ^ meta.tag.hamlet punctuation.definition.tag.begin.hamlet
$# ^ meta.tag.hamlet entity.name.tag.hamlet
$# ^ meta.tag.hamlet punctuation.definition.tag.end.hamlet
$elseif isLoggedIn
$# <------- meta.interpolation.hamlet keyword.control.hamlet
$# ^ - keyword.control.hamlet
$# ^^^^^^^^^^ meta.interpolation.hamlet source.haskell.embedded
<p>You are not the administrator.
$# ^ meta.tag.hamlet punctuation.definition.tag.begin.hamlet
$# ^ meta.tag.hamlet entity.name.tag.hamlet
$# ^ meta.tag.hamlet punctuation.definition.tag.end.hamlet
$else
$# <---- meta.interpolation.hamlet keyword.control.hamlet
$# ^ - keyword.control.hamlet
<p>I don't know who you are. Please log in so I can decide if you get access.
$# ^ meta.tag.hamlet punctuation.definition.tag.begin.hamlet
$# ^ meta.tag.hamlet entity.name.tag.hamlet
$# ^ meta.tag.hamlet punctuation.definition.tag.end.hamlet
12 changes: 12 additions & 0 deletions test/tests/hamlet/interpolation.hamlet
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$# SYNTAX TEST "source.yesod.hamlet" "interpolation"
<head>
$# <- meta.tag.hamlet punctuation.definition.tag.begin.hamlet
$# <~---- meta.tag.hamlet entity.name.tag.hamlet
$# ^ meta.tag.hamlet punctuation.definition.tag.end.hamlet
<title>#{title}
$# ^ meta.tag.hamlet punctuation.definition.tag.begin.hamlet
$# ^^^^^ meta.tag.hamlet entity.name.tag.hamlet
$# ^ meta.tag.hamlet punctuation.definition.tag.end.hamlet
$# ^^ meta.interpolation.hamlet punctuation.section.interpolation.begin.hamlet
$# ^^^^^ meta.interpolation.hamlet source.haskell.embedded
$# ^ meta.interpolation.hamlet punctuation.section.interpolation.end.hamlet

0 comments on commit 8c72884

Please sign in to comment.