mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 19:17:09 +03:00
update tests
?. is illegal in new update console methods timeStamp has the same support as profile and both are nonstandard so they're both included update global classes Wait a minute, Generator and GeneratorFunction are _not_ global... so actually just any class specified in ECMA262 non global additions: - AsyncFunction - AsyncGeneratorFunction - TypedArray luckily MDN's sidebar of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis shows all of these Wait... JSON? That's not a class Math has the scope support.class.math.js for some reason so I guess add "json" likewise for json Never knew about WeakRef and FinalizationRegistry Wonder why it's so unknown; this is a common idea in Rust at least.... So yeah, JSON is separate just like Math Lots of copying and pasting rest vs spread depends on context I don't know why that test failed
This commit is contained in:
parent
ff54809dbc
commit
dcb3cda149
@ -1,5 +1,6 @@
|
||||
# Note: Because of the optional chaining operator (?.), "object.property" in the comments usually means ("object.property" or "object?.property")
|
||||
# Even though sometimes it doesn't seem like using the chaining operator would make any sense, it's still supported. example: Math?.PI
|
||||
# "?." means "?." or "."
|
||||
# Even though sometimes it doesn't seem like using the chaining operator would make any sense, it's still supported.
|
||||
# Example: Math?.PI
|
||||
# Negative look-behinds for "." should cover "?."
|
||||
'scopeName': 'source.js'
|
||||
'fileTypes': [
|
||||
@ -540,7 +541,7 @@
|
||||
]
|
||||
}
|
||||
{
|
||||
# [.|?.]foo = ... => ...
|
||||
# [?.]foo = ... => ...
|
||||
'begin': '''(?x)
|
||||
(?=
|
||||
(\\?\\.|\\.)?[a-zA-Z_$][\\w$]*
|
||||
@ -731,7 +732,7 @@
|
||||
'name': 'meta.class.js'
|
||||
}
|
||||
{
|
||||
'match': '(new)\\s+([\\w$]+[\\w.$]*)'
|
||||
'match': '(new)\\s+([\\w$]+(?:\\??\\.[\\w$]*)*)'
|
||||
'name': 'meta.class.instance.constructor.js'
|
||||
'captures':
|
||||
'1':
|
||||
@ -740,7 +741,7 @@
|
||||
'name': 'entity.name.type.instance.js'
|
||||
'patterns': [
|
||||
{
|
||||
'include': '#period_or_optional_property'
|
||||
'include': '#period_or_illegal_optional_property'
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -754,7 +755,9 @@
|
||||
'end': '''(?x)
|
||||
(?<=\\)) | (?=
|
||||
(?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*
|
||||
(assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn)
|
||||
(assert|clear|count|countReset|debug|dir|dirxml|error|group|groupCollapsed|
|
||||
groupEnd|info|log|profile|profileEnd|table|time|timeEnd|timeLog|trace|
|
||||
timeStamp|warn)
|
||||
\\s*\\(
|
||||
)) \\s*\\S
|
||||
)
|
||||
@ -784,6 +787,45 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
# JSON
|
||||
'begin': '(?<![\\w$])JSON(?![\\w$]|\\s*:)'
|
||||
'beginCaptures':
|
||||
'0':
|
||||
'name': 'support.class.json.js'
|
||||
'end': '''(?x)
|
||||
(?<=\\)) | (?=
|
||||
(?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*
|
||||
(parse|stringify)
|
||||
\\s*\\(
|
||||
)) \\s*\\S
|
||||
)
|
||||
'''
|
||||
'patterns': [
|
||||
{
|
||||
'include': '#comments'
|
||||
}
|
||||
{
|
||||
'begin': '\\s*(\\?\\.|\\.)\\s*(\\w+)\\s*(?=\\()'
|
||||
'beginCaptures':
|
||||
'1':
|
||||
'patterns': [
|
||||
{
|
||||
'include': '#period_or_optional_method'
|
||||
}
|
||||
]
|
||||
'2':
|
||||
'name': 'support.function.json.js'
|
||||
'end': '(?<=\\))'
|
||||
'name': 'meta.method-call.js'
|
||||
'patterns': [
|
||||
{
|
||||
'include': '#arguments'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
# Math
|
||||
'begin': '(?<![\\w$])Math(?![\\w$]|\\s*:)'
|
||||
@ -848,7 +890,7 @@
|
||||
'name': 'support.class.promise.js'
|
||||
'end': '''(?x)
|
||||
(?<=\\)) | (?=
|
||||
(?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*(all|race|reject|resolve)\\s*\\() )\\s*\\S
|
||||
(?! (\\s*//)|(\\s*/\\*)|(\\s*(\\?\\.|\\.)\\s*(all|allSettled|any|race|reject|resolve)\\s*\\() )\\s*\\S
|
||||
)
|
||||
'''
|
||||
'patterns': [
|
||||
@ -982,14 +1024,12 @@
|
||||
'match': '(?<!\\.)\\b(delete|in|of|instanceof|new|typeof|void)(?!\\s*:)\\b'
|
||||
'name': 'keyword.operator.$1.js'
|
||||
}
|
||||
# By default, three dots = spread
|
||||
# `keyword.operator.rest.js` is only done in specific cases in functions
|
||||
{
|
||||
'match': '\\.\\.\\.'
|
||||
'name': 'keyword.operator.spread.js'
|
||||
}
|
||||
{
|
||||
'match': '\\.\\.\\.'
|
||||
'name': 'keyword.operator.rest.js'
|
||||
}
|
||||
{
|
||||
'match': '(?<!\\.)\\b(true|false)(?!\\s*:)\\b'
|
||||
'name': 'constant.language.boolean.$1.js'
|
||||
@ -1004,10 +1044,11 @@
|
||||
}
|
||||
{
|
||||
'match': '''(?x) (?<!\\$) \\b
|
||||
(AggregateError|Array|ArrayBuffer|Atomics|Boolean|DataView|Date|Error|EvalError|Float32Array|Float64Array
|
||||
|Function|Generator|GeneratorFunction|Int16Array|Int32Array|Int8Array|InternalError|Intl|JSON|Map|Number
|
||||
(AggregateError|Array|ArrayBuffer|AsyncFunction|AsyncGeneratorFunction|Atomics|BigInt|BigInt64Array
|
||||
|BigUInt64Array|Boolean|DataView|Date|Error|EvalError|FinalizationRegistry|Float32Array|Float64Array
|
||||
|Function|Generator|GeneratorFunction|Int16Array|Int32Array|Int8Array|InternalError|Intl|Map|Number
|
||||
|Object|Proxy|RangeError|ReferenceError|Reflect|RegExp|Set|SharedArrayBuffer|SIMD|String|Symbol|SyntaxError
|
||||
|TypeError|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|URIError|WeakMap|WeakSet)
|
||||
|TypedArray|TypeError|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|URIError|WeakMap|WeakRef|WeakSet)
|
||||
\\b
|
||||
'''
|
||||
'name': 'support.class.js'
|
||||
@ -1501,6 +1542,12 @@
|
||||
'1':
|
||||
'name': 'entity.name.function.js'
|
||||
'2':
|
||||
'patterns': [
|
||||
{
|
||||
'include': '#period_or_optional_method'
|
||||
}
|
||||
]
|
||||
'3':
|
||||
'name': 'punctuation.definition.string.begin.js'
|
||||
'end': '`'
|
||||
'endCaptures':
|
||||
@ -2242,6 +2289,17 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
'period_or_illegal_optional_property':
|
||||
'patterns': [
|
||||
{
|
||||
'match': '\\.'
|
||||
'name': 'meta.delimiter.property.period.js'
|
||||
}
|
||||
{
|
||||
'match': '\\?\\.'
|
||||
'name': 'invalid.illegal.meta.delimiter.property.optional.js'
|
||||
}
|
||||
]
|
||||
'period_or_optional_property':
|
||||
'patterns': [
|
||||
{
|
||||
|
@ -936,22 +936,26 @@ describe "JavaScript grammar", ->
|
||||
describe "ES6 tagged Relay.QL string templates", ->
|
||||
it "tokenizes them as strings", ->
|
||||
{tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { id }`')
|
||||
expect(tokens[0]).toEqual value: 'Relay.QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js']
|
||||
expect(tokens[2]).toEqual value: 'fragment on Foo { id }', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js']
|
||||
expect(tokens[0]).toEqual value: 'Relay', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'string.quoted.template.graphql.js', 'meta.delimiter.method.period.js']
|
||||
expect(tokens[2]).toEqual value: 'QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js']
|
||||
expect(tokens[4]).toEqual value: 'fragment on Foo { id }', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[5]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js']
|
||||
|
||||
describe "ES6 tagged Relay.QL string templates with interpolation", ->
|
||||
it "tokenizes them as strings", ->
|
||||
{tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { ${myFragment} }`')
|
||||
expect(tokens[0]).toEqual value: 'Relay.QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js']
|
||||
expect(tokens[2]).toEqual value: 'fragment on Foo { ', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js']
|
||||
expect(tokens[4]).toEqual value: 'myFragment', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source']
|
||||
expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js']
|
||||
expect(tokens[6]).toEqual value: ' }', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js']
|
||||
expect(tokens[0]).toEqual value: 'Relay', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'string.quoted.template.graphql.js', 'meta.delimiter.method.period.js']
|
||||
expect(tokens[2]).toEqual value: 'QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js']
|
||||
expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js']
|
||||
expect(tokens[4]).toEqual value: 'fragment on Foo { ', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[5]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js']
|
||||
expect(tokens[6]).toEqual value: 'myFragment', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source']
|
||||
expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js']
|
||||
expect(tokens[8]).toEqual value: ' }', scopes: ['source.js', 'string.quoted.template.graphql.js']
|
||||
expect(tokens[9]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js']
|
||||
|
||||
describe "ES6 tagged gql string templates", ->
|
||||
it "tokenizes them as strings", ->
|
||||
@ -1920,7 +1924,7 @@ describe "JavaScript grammar", ->
|
||||
expect(tokens[2]).toEqual value: ')', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js']
|
||||
expect(tokens[3]).toEqual value: '?.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.optional.js']
|
||||
expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js']
|
||||
|
||||
|
||||
{tokens} = grammar.tokenizeLine('a()?.MY_CONSTANT')
|
||||
expect(tokens[0]).toEqual value: 'a', scopes: ['source.js', 'meta.function-call.js', 'entity.name.function.js']
|
||||
expect(tokens[3]).toEqual value: '?.', scopes: ['source.js', 'meta.delimiter.property.optional.js']
|
||||
@ -2145,6 +2149,41 @@ describe "JavaScript grammar", ->
|
||||
{tokens} = grammar.tokenizeLine('console .foo();')
|
||||
expect(tokens[3]).toEqual value: 'foo', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js']
|
||||
|
||||
describe "json", ->
|
||||
it "tokenizes the json object", ->
|
||||
{tokens} = grammar.tokenizeLine('JSON;')
|
||||
expect(tokens[0]).toEqual value: 'JSON', scopes: ['source.js', 'support.class.json.js']
|
||||
expect(tokens[1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']
|
||||
|
||||
it "tokenizes json support functions", ->
|
||||
{tokens} = grammar.tokenizeLine('JSON.parse();')
|
||||
expect(tokens[0]).toEqual value: 'JSON', scopes: ['source.js', 'support.class.json.js']
|
||||
expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js']
|
||||
expect(tokens[2]).toEqual value: 'parse', scopes: ['source.js', 'meta.method-call.js', 'support.function.json.js']
|
||||
expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js']
|
||||
expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js']
|
||||
expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']
|
||||
|
||||
lines = grammar.tokenizeLines '''
|
||||
JSON
|
||||
.parse();
|
||||
'''
|
||||
expect(lines[0][0]).toEqual value: 'JSON', scopes: ['source.js', 'support.class.json.js']
|
||||
expect(lines[1][0]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js']
|
||||
expect(lines[1][1]).toEqual value: 'parse', scopes: ['source.js', 'meta.method-call.js', 'support.function.json.js']
|
||||
expect(lines[1][2]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js']
|
||||
expect(lines[1][3]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js']
|
||||
expect(lines[1][4]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']
|
||||
|
||||
it "tokenizes json custom functions", ->
|
||||
{tokens} = grammar.tokenizeLine('JSON.pi();')
|
||||
expect(tokens[0]).toEqual value: 'JSON', scopes: ['source.js', 'support.class.json.js']
|
||||
expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js']
|
||||
expect(tokens[2]).toEqual value: 'pi', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js']
|
||||
expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js']
|
||||
expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js']
|
||||
expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']
|
||||
|
||||
describe "math", ->
|
||||
it "tokenizes the math object", ->
|
||||
{tokens} = grammar.tokenizeLine('Math;')
|
||||
|
Loading…
Reference in New Issue
Block a user