Skip to content
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

Hamlet testcases -- interpolation and conditional #25

Merged
merged 9 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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