Skip to content

Commit

Permalink
Pony markup tests + language improvements (#1958)
Browse files Browse the repository at this point in the history
* Added some tests. Still not happy with class definition highlighting
* Got class highlighting working as I would like and added additional tests
  • Loading branch information
gregcline authored and egor-rogov committed Jan 29, 2019
1 parent 5b5e907 commit 6ffbe78
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/languages/pony.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@ function(hljs) {

var CLASS = {
className: 'class',
beginKeywords: 'class actor object', end: '$',
beginKeywords: 'class actor object primitive', end: '$',
contains: [
{
className: 'keyword',
begin: 'is'
},
TYPE_NAME,
hljs.TITLE_MODE,
hljs.C_LINE_COMMENT_MODE
]
}

var FUNCTION = {
className: 'function',
beginKeywords: 'new fun', end: '=>',
beginKeywords: 'new fun be', end: '=>',
contains: [
hljs.TITLE_MODE,
{
Expand Down
3 changes: 3 additions & 0 deletions test/markup/pony/creator.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span class="hljs-function"><span class="hljs-keyword">new</span> <span class="hljs-title">create</span>(env: <span class="hljs-type">Env</span>, name: <span class="hljs-type">String</span>) =&gt;</span>
_env = env
_name = name
3 changes: 3 additions & 0 deletions test/markup/pony/creator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
new create(env: Env, name: String) =>
_env = env
_name = name
1 change: 1 addition & 0 deletions test/markup/pony/lambda.expect.xt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{(foo: <span class="hljs-type">I32</span>)(bar): <span class="hljs-type">String</span> =&gt; (foo + bar).string()}
1 change: 1 addition & 0 deletions test/markup/pony/lambda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{(foo: I32)(bar): String => (foo + bar).string()}
8 changes: 8 additions & 0 deletions test/markup/pony/match.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span class="hljs-keyword">match</span> foo
| <span class="hljs-literal">true</span> =&gt; <span class="hljs-string">"it's true"</span>
| <span class="hljs-string">"bar"</span> =&gt; <span class="hljs-string">"it's bar"</span>
| <span class="hljs-keyword">let</span> x: <span class="hljs-type">I32</span> <span class="hljs-keyword">if</span> x &gt; <span class="hljs-number">3</span> =&gt; <span class="hljs-string">"it's greater than 3"</span>
| <span class="hljs-keyword">let</span> x: <span class="hljs-type">I32</span> =&gt; <span class="hljs-string">"it's less than or equal to 3"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"I don't know what it is"</span>
<span class="hljs-keyword">end</span>
8 changes: 8 additions & 0 deletions test/markup/pony/match.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
match foo
| true => "it's true"
| "bar" => "it's bar"
| let x: I32 if x > 3 => "it's greater than 3"
| let x: I32 => "it's less than or equal to 3"
else
"I don't know what it is"
end
8 changes: 8 additions & 0 deletions test/markup/pony/method.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">foo</span>(bar: <span class="hljs-type">String</span>): <span class="hljs-type">String</span> =&gt;</span>
bar + <span class="hljs-string">"baz"</span>

<span class="hljs-function"><span class="hljs-keyword">new</span> <span class="hljs-title">create</span>(hunger: <span class="hljs-type">I32</span>) =&gt;</span>
_hunger = hunger

<span class="hljs-function"><span class="hljs-keyword">be</span> <span class="hljs-title">feed</span>(food: <span class="hljs-type">I32</span>) =&gt;</span>
_hunger = _hunger - food
8 changes: 8 additions & 0 deletions test/markup/pony/method.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fun foo(bar: String): String =>
bar + "baz"

new create(hunger: I32) =>
_hunger = hunger

be feed(food: I32) =>
_hunger = _hunger - food
7 changes: 7 additions & 0 deletions test/markup/pony/objects.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<span class="hljs-class"><span class="hljs-keyword">primitive</span> <span class="hljs-type">I32</span> <span class="hljs-keyword">is</span> <span class="hljs-type">SignedInteger</span></span>

<span class="hljs-class"><span class="hljs-keyword">actor</span> <span class="hljs-type">Main</span></span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ref</span> <span class="hljs-type">List</span>[<span class="hljs-type">A</span>: <span class="hljs-type">A</span>] <span class="hljs-keyword">is</span> <span class="hljs-type">Seq</span>[<span class="hljs-type">A</span>] <span class="hljs-title">ref</span></span>

<span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-keyword">is</span> <span class="hljs-type">Hashable</span></span>
7 changes: 7 additions & 0 deletions test/markup/pony/objects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
primitive I32 is SignedInteger

actor Main

class ref List[A: A] is Seq[A] ref

object is Hashable
5 changes: 5 additions & 0 deletions test/markup/pony/triple-quote.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span class="hljs-string">"""
A triple quoted string
* Goes several lines
* Keeps formatting
"""</span>
5 changes: 5 additions & 0 deletions test/markup/pony/triple-quote.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
A triple quoted string
* Goes several lines
* Keeps formatting
"""

0 comments on commit 6ffbe78

Please sign in to comment.