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

Yesodroute testcase #24

Merged
merged 10 commits into from
Mar 20, 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
3 changes: 3 additions & 0 deletions .github/workflows/vscode-language-yesod-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ jobs:

- name: Test Hamlet's syntax highlighting
run: npx vscode-tmgrammar-test -s source.yesod.hamlet -g syntaxes/hamlet.tmLanguage.json -t "test/tests/hamlet/*.hamlet"

- name: Test Routes' syntax highlighting
run: npx vscode-tmgrammar-test -s source.yesod.routes -g syntaxes/routes.tmLanguage.json -t "test/tests/routes/*.yesodroutes"
30 changes: 29 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,39 @@
]
}
},
{
"label": "Run routes tests",
"type": "shell",
"command": "npx vscode-tmgrammar-test -c -s source.yesod.routes -g syntaxes/routes.tmLanguage.json -t \"test/tests/routes/*.yesodroutes\"",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": [
{
"regexp": "^(ERROR)\\s([^:]+):(\\d+):(\\d+):(\\d+)\\s(.*)$",
"severity": 1,
"file": 2,
"line": 3,
"column": 4,
"endColumn": 5,
"message": 6
}
]
}
},
{
"label": "Run all tests",
"dependsOn": [
"Run hamlet tests",
"Run cassius tests"
"Run cassius tests",
"Run routes tests"
]
}
]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the "language-yesod" extension will be documented in this

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Added a test case for route declarations. [#24](https://github.com/e-bigmoon/vscode-language-yesod/pull/24)

## [0.7.0] - 2021-03-13

- Added CI with Github actions
Expand Down
52 changes: 31 additions & 21 deletions syntaxes/routes.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,45 @@
"toplevel": {
"patterns": [
{
"begin": "^\\s*[/!]",
"begin": "^\\s*",
"end": "\n",
"name": "meta.url.route.yesod",
"patterns": [
{
"match": "[#*+]!?[A-Z][a-zA-Z0-9]+",
"name": "support.type.patterns"
"include": "#comment"
},
{
"match": "\\b([A-Z][a-zA-Z0-9]+R)\\b",
"name": "constant.other.handler"
},
{
"match": "(GET|HEAD|POST|PUT|DELETE|OPTIONS|PATCH)",
"name": "entity.name.function"
},
{
"match": "![a-zA-Z0-9]+",
"name": "entity.other.attribute-name"
},
{
"match": "--.*",
"name": "comment.line"
"begin": "[/!]",
"name": "meta.url.route.yesod",
"patterns": [
{
"match": "[#*+]!?[A-Z][a-zA-Z0-9]+",
"name": "support.type.patterns"
},
{
"match": "\\b([A-Z][a-zA-Z0-9]+R)\\b",
"name": "constant.other.handler"
},
{
"match": "(GET|HEAD|POST|PUT|DELETE|OPTIONS|PATCH)",
"name": "entity.name.function"
},
{
"match": "![a-zA-Z0-9]+",
"name": "entity.other.attribute-name"
},
{
"include": "#comment"
}
]
}
]
},
}
]
},
"comment": {
"patterns": [
{
"begin": "^\\s*--",
"end": "\n",
"match": "--.*$",
"name": "comment.line"
}
]
Expand Down
14 changes: 14 additions & 0 deletions test/tests/routes/attribute.yesodroutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- SYNTAX TEST "source.yesod.routes" "attribute"

/admin AdminR !admin:
-- <-------------- - entity.other.attribute-name
-- ^^^^^^ entity.other.attribute-name
/1 Admin1R GET !1
-- ^^^^^^^^^^^^^^^ - entity.other.attribute-name
-- ^^ entity.other.attribute-name
/2 Admin2R GET !2
-- ^^^^^^^^^^^^^^^ - entity.other.attribute-name
-- ^^ entity.other.attribute-name
/3 Admin3R GET !3
-- ^^^^^^^^^^^^^^^ - entity.other.attribute-name
-- ^^ entity.other.attribute-name
9 changes: 9 additions & 0 deletions test/tests/routes/comment.yesodroutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- SYNTAX TEST "source.yesod.routes" "comment line"

-- comment
-- <-- - comment.line
-- ^^^^^^^^^^ comment.line

/ HomeR GET-- comment
-- <--------------------------- - comment.line
-- ^^^^^^^^^^ comment.line
18 changes: 18 additions & 0 deletions test/tests/routes/handler.yesodroutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- SYNTAX TEST "source.yesod.routes" "handler"

/foo1 Foo1R GET
-- <-------------- - constant.other.handler
-- ^^^^^ constant.other.handler
-- ^^^^^^^^ - constant.other.handler
/foo2 Foo2R HEAD
-- <-------------- - constant.other.handler
-- ^^^^^ constant.other.handler
-- ^^^^^^^^^ - constant.other.handler
/multi MultiR GET POST
-- <-------------- - constant.other.handler
-- ^^^^^^ constant.other.handler
-- ^^^^^^^^^^^^ - constant.other.handler
/blog/#BlogId BlogPostR GET POST
-- <-------------- - constant.other.handler
-- ^^^^^^^^^ constant.other.handler
-- ^^^^^^^^^ - constant.other.handler
29 changes: 29 additions & 0 deletions test/tests/routes/method.yesodroutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- SYNTAX TEST "source.yesod.routes" "http methods"

/foo1 Foo1R GET
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo2 Foo2R HEAD
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo3 Foo3R POST
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo4 Foo4R PUT
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo5 Foo5R DELETE
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo6 Foo6R OPTIONS
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/foo7 Foo7R PATCH
-- <------------------------ - entity.name.function
-- ^^^ entity.name.function
/multi MultiR GET POST
-- <------------------------ - entity.name.function
-- ^^^ ^^^^ entity.name.function
/blog/#BlogId BlogPostR GET POST
-- <------------------------ - entity.name.function
-- ^^^ ^^^^ entity.name.function
17 changes: 17 additions & 0 deletions test/tests/routes/pattern.yesodroutes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- SYNTAX TEST "source.yesod.routes" "pattern"

/foo/bar Foo1R GET
-- <-------------------- - support.type.patterns
/foo/#Text Foo2R GET
-- <----- - support.type.patterns
-- ^^^^^ support.type.patterns
-- ^^^^^^^^^^ - support.type.patterns
/foo/bar Foo1R GET
!/foo/#Int Foo2R GET
-- <------ - support.type.patterns
-- ^^^^ support.type.patterns
-- ^^^^^^^^^^^ - support.type.patterns
!/foo/#Text Foo3R GET
-- <------ - support.type.patterns
-- ^^^^^ support.type.patterns
-- ^^^^^^^^^^ - support.type.patterns