Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added tests
  • Loading branch information
RunDevelopment committed Feb 15, 2019
commit 9b250ac65e234e4cb8a072518268fde3eda397ca
2 changes: 1 addition & 1 deletion components/prism-js-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

Prism.languages.insertBefore('javascript', 'keyword', {
'module': {
pattern: /\b(?:import|as|export|from|default)\b/,
pattern: /\b(?:as|default|export|from|import)\b/,
alias: 'keyword'
},
'nil': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-js-extras.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions tests/languages/javascript!+js-extras/arrow_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
() => {};
a => a;

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

[
["punctuation", "("],
["punctuation", ")"],
["arrow", "=>"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ";"],

["parameter", ["a"]],
["arrow", "=>"],
" a",
["punctuation", ";"]
]

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

Checks for function arrows.
12 changes: 12 additions & 0 deletions tests/languages/javascript!+js-extras/console_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
console.

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

[
["console", "console"],
["punctuation", "."]
]

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

Checks for the console variable being used.
23 changes: 23 additions & 0 deletions tests/languages/javascript!+js-extras/dom_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
document
location
navigator
performance
localStorage
sessionStorage
window

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

[
["dom", "document"],
["dom", "location"],
["dom", "navigator"],
["dom", "performance"],
["dom", "localStorage"],
["dom", "sessionStorage"],
["dom", "window"]
]

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

Checks for the important DOM variables being used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Int8Array
Int16Array
Int32Array
Uint8Array
Uint16Array
Uint32Array
Uint8ClampedArray
Float32Array
Float64Array
Array
ArrayBuffer
BigInt
Boolean
DataView
Date
Error
Function
Intl
JSON
Math
Number
Object
Promise
Proxy
Reflect
RegExp
String
Symbol
Set
Map
WeakSet
WeakMap
WebAssembly

InternalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError

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

[
["known-class-name", "Int8Array"],
["known-class-name", "Int16Array"],
["known-class-name", "Int32Array"],
["known-class-name", "Uint8Array"],
["known-class-name", "Uint16Array"],
["known-class-name", "Uint32Array"],
["known-class-name", "Uint8ClampedArray"],
["known-class-name", "Float32Array"],
["known-class-name", "Float64Array"],
["known-class-name", "Array"],
["known-class-name", "ArrayBuffer"],
["known-class-name", "BigInt"],
["known-class-name", "Boolean"],
["known-class-name", "DataView"],
["known-class-name", "Date"],
["known-class-name", "Error"],
["known-class-name", "Function"],
["known-class-name", "Intl"],
["known-class-name", "JSON"],
["known-class-name", "Math"],
["known-class-name", "Number"],
["known-class-name", "Object"],
["known-class-name", "Promise"],
["known-class-name", "Proxy"],
["known-class-name", "Reflect"],
["known-class-name", "RegExp"],
["known-class-name", "String"],
["known-class-name", "Symbol"],
["known-class-name", "Set"],
["known-class-name", "Map"],
["known-class-name", "WeakSet"],
["known-class-name", "WeakMap"],
["known-class-name", "WebAssembly"],

["known-class-name", "InternalError"],
["known-class-name", "RangeError"],
["known-class-name", "ReferenceError"],
["known-class-name", "SyntaxError"],
["known-class-name", "TypeError"],
["known-class-name", "URIError"]
]

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

Checks for known class names.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Foo.Bar;
Foo.Bar();
Baz.foo();
var Foo = function() {};
foo.Bar = function() {};

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

[
["maybe-class-name", "Foo"],
["punctuation", "."],
["property-access", [
["maybe-class-name", "Bar"]
]],
["punctuation", ";"],

["maybe-class-name", "Foo"],
["punctuation", "."],
["method", [
["maybe-class-name", "Bar"]
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],

["maybe-class-name", "Baz"],
["punctuation", "."],
["method", [
"foo"
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],

["keyword", "var"],
["function-variable", [
["maybe-class-name", "Foo"]
]],
["operator", "="],
["keyword", "function"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ";"],

"\nfoo",
["punctuation", "."],
["method-variable", [
["maybe-class-name", "Bar"]
]],
["operator", "="],
["keyword", "function"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ";"]
]

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

Checks for names which may be class names.
37 changes: 37 additions & 0 deletions tests/languages/javascript!+js-extras/method-variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
foo.bar = function() {};
foo.bar = async () => {};

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

[
"foo",
["punctuation", "."],
["method-variable", [
"bar"
]],
["operator", "="],
["keyword", "function"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ";"],

"\nfoo",
["punctuation", "."],
["method-variable", [
"bar"
]],
["operator", "="],
["keyword", "async"],
["punctuation", "("],
["punctuation", ")"],
["arrow", "=>"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ";"]
]

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

Checks for method variables.
32 changes: 32 additions & 0 deletions tests/languages/javascript!+js-extras/method_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
foo.bar();
foo.bar.call();

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

[
"foo",
["punctuation", "."],
["method", [
"bar"
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],

"\nfoo",
["punctuation", "."],
["method", [
"bar"
]],
["punctuation", "."],
["method", [
"call"
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"]
]

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

Checks for methods.
19 changes: 19 additions & 0 deletions tests/languages/javascript!+js-extras/module_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
as
default
export
from
import

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

[
["module", "as"],
["module", "default"],
["module", "export"],
["module", "from"],
["module", "import"]
]

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

Checks for keywords used for imports and exports.
13 changes: 13 additions & 0 deletions tests/languages/javascript!+js-extras/nil_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
null; undefined

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

[
["nil", "null"],
["punctuation", ";"],
["nil", "undefined"]
]

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

Checks for null and undefined.
22 changes: 22 additions & 0 deletions tests/languages/javascript!+js-extras/property-access_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
foo.bar.baz = 0;

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

[
"foo",
["punctuation", "."],
["property-access", [
"bar"
]],
["punctuation", "."],
["property-access", [
"baz"
]],
["operator", "="],
["number", "0"],
["punctuation", ";"]
]

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

Checks for property access.
11 changes: 11 additions & 0 deletions tests/languages/javascript!+js-extras/spread_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
...foo

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

[
["spread", "..."], "foo"
]

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

Checks for spread operators.