Skip to content

Commit

Permalink
Add some simple test cases for the protobuf language
Browse files Browse the repository at this point in the history
This patch adds basic test cases for the protobuf language and
fixes some whitespace issues. It also adds the missing
requirement to the clike language to components.js.
  • Loading branch information
zeitgeist87 committed Apr 30, 2016
1 parent 2746d7f commit 3eec2b7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
1 change: 1 addition & 0 deletions components.js
Expand Up @@ -399,6 +399,7 @@ var components = {
},
"protobuf": {
"title": "Protocol Buffers",
"require": "clike",
"owner": "just-boris"
},
"puppet": {
Expand Down
12 changes: 6 additions & 6 deletions components/prism-protobuf.js
@@ -1,8 +1,8 @@
Prism.languages.protobuf = Prism.languages.extend('clike', {
keyword: /\b(package|import|message|enum)\b/,
builtin: /\b(required|repeated|optional|reserved)\b/,
primitive: {
pattern: /\b(double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|bool|string|bytes)\b/,
alias: 'symbol'
}
keyword: /\b(package|import|message|enum)\b/,
builtin: /\b(required|repeated|optional|reserved)\b/,
primitive: {
pattern: /\b(double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|bool|string|bytes)\b/,
alias: 'symbol'
}
});
40 changes: 40 additions & 0 deletions tests/languages/protobuf/keyword_feature.test
@@ -0,0 +1,40 @@
message Point {
required int32 x = 1;
required int32 y = 2;
optional string label = 3;
}

----------------------------------------------------

[
["keyword", "message"],
" Point ",
["punctuation", "{"],

["builtin", "required"],
["primitive", "int32"],
" x ",
["operator", "="],
["number", "1"],
["punctuation", ";"],

["builtin", "required"],
["primitive", "int32"],
" y ",
["operator", "="],
["number", "2"],
["punctuation", ";"],

["builtin", "optional"],
["primitive", "string"],
" label ",
["operator", "="],
["number", "3"],
["punctuation", ";"],

["punctuation", "}"]
]

----------------------------------------------------

Check for keywords and builtins
23 changes: 23 additions & 0 deletions tests/languages/protobuf/string_feature.test
@@ -0,0 +1,23 @@
""
''
"foo"
'foo'
"'foo'"
'"bar"'
" // comment "

----------------------------------------------------

[
["string", "\"\""],
["string", "''"],
["string", "\"foo\""],
["string", "'foo'"],
["string", "\"'foo'\""],
["string", "'\"bar\"'"],
["string", "\" // comment \""]
]

----------------------------------------------------

Checks for single-quoted and double-quoted strings.

0 comments on commit 3eec2b7

Please sign in to comment.