mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Address newly failing tests
This commit is contained in:
parent
50bfa5141e
commit
865153b471
@ -1,21 +1,26 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
describe('Hyperlink grammar', function() {
|
describe('Hyperlink grammar', function () {
|
||||||
let grammar = null;
|
let grammar = null;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function () {
|
||||||
|
// TODO: All these specs rely on the ability of a grammar to tokenize a
|
||||||
|
// line in isolation, which is something that a `WASMTreeSitterGrammar`
|
||||||
|
// cannot do. This package will need specialized tests for the modern
|
||||||
|
// Tree-sitter world the same way that most other language packages do.
|
||||||
|
atom.config.set('core.useTreeSitterParsers', false);
|
||||||
waitsForPromise(() => atom.packages.activatePackage('language-hyperlink'));
|
waitsForPromise(() => atom.packages.activatePackage('language-hyperlink'));
|
||||||
|
|
||||||
runs(() => grammar = atom.grammars.grammarForScopeName('text.hyperlink'));
|
runs(() => grammar = atom.grammars.grammarForScopeName('text.hyperlink'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses the grammar', function() {
|
it('parses the grammar', function () {
|
||||||
expect(grammar).toBeTruthy();
|
expect(grammar).toBeTruthy();
|
||||||
expect(grammar.scopeName).toBe('text.hyperlink');
|
expect(grammar.scopeName).toBe('text.hyperlink');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses http: and https: links', function() {
|
it('parses http: and https: links', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
|
|
||||||
let {tokens} = plainGrammar.tokenizeLine('http://github.com');
|
let {tokens} = plainGrammar.tokenizeLine('http://github.com');
|
||||||
@ -29,16 +34,16 @@ describe('Hyperlink grammar', function() {
|
|||||||
|
|
||||||
({tokens} = plainGrammar.tokenizeLine('https://github.com/atom/brightray_example'));
|
({tokens} = plainGrammar.tokenizeLine('https://github.com/atom/brightray_example'));
|
||||||
expect(tokens[0]).toEqual({value: 'https://github.com/atom/brightray_example', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'https://github.com/atom/brightray_example', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses http: and https: links that contains unicode characters', function() {
|
it('parses http: and https: links that contains unicode characters', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
|
|
||||||
const {tokens} = plainGrammar.tokenizeLine('https://sv.wikipedia.org/wiki/Mañana');
|
const {tokens} = plainGrammar.tokenizeLine('https://sv.wikipedia.org/wiki/Mañana');
|
||||||
expect(tokens[0]).toEqual({value: 'https://sv.wikipedia.org/wiki/Mañana', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'https://sv.wikipedia.org/wiki/Mañana', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses other links', function() {
|
it('parses other links', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
|
|
||||||
let {tokens} = plainGrammar.tokenizeLine('mailto:noreply@example.com');
|
let {tokens} = plainGrammar.tokenizeLine('mailto:noreply@example.com');
|
||||||
@ -49,55 +54,57 @@ describe('Hyperlink grammar', function() {
|
|||||||
|
|
||||||
({tokens} = plainGrammar.tokenizeLine('atom://core/open/file?filename=urlEncodedFileName&line=n&column=n'));
|
({tokens} = plainGrammar.tokenizeLine('atom://core/open/file?filename=urlEncodedFileName&line=n&column=n'));
|
||||||
expect(tokens[0]).toEqual({value: 'atom://core/open/file?filename=urlEncodedFileName&line=n&column=n', scopes: ['text.plain.null-grammar', 'markup.underline.link.atom.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'atom://core/open/file?filename=urlEncodedFileName&line=n&column=n', scopes: ['text.plain.null-grammar', 'markup.underline.link.atom.hyperlink']});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not parse links in a regex string', function() {
|
it('does not parse links in a regex string', function () {
|
||||||
const testGrammar = atom.grammars.loadGrammarSync(path.join(__dirname, 'fixtures', 'test-grammar.cson'));
|
const testGrammar = atom.grammars.loadGrammarSync(path.join(__dirname, 'fixtures', 'test-grammar.cson'));
|
||||||
|
|
||||||
const {tokens} = testGrammar.tokenizeLine('regexp:http://github.com');
|
const {tokens} = testGrammar.tokenizeLine('regexp:http://github.com');
|
||||||
expect(tokens[1]).toEqual({value: 'http://github.com', scopes: ['source.test', 'string.regexp.test']});
|
expect(tokens[1]).toEqual({value: 'http://github.com', scopes: ['source.test', 'string.regexp.test']});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parsing PHP strings', () => it('does not parse links in a regex string', function() {
|
describe('parsing PHP strings', () => {
|
||||||
// PHP is unique in that its root scope is `text.html.php`, meaning that even though
|
it('does not parse links in a regex string', function () {
|
||||||
// `string - string.regexp` won't match in a regex string, `text` still will.
|
// PHP is unique in that its root scope is `text.html.php`, meaning that even though
|
||||||
// This is the reason the injection selector is `text - string.regexp` instead.
|
// `string - string.regexp` won't match in a regex string, `text` still will.
|
||||||
// https://github.com/atom/language-php/issues/219
|
// This is the reason the injection selector is `text - string.regexp` instead.
|
||||||
|
// https://github.com/atom/language-php/issues/219
|
||||||
|
|
||||||
waitsForPromise(() => atom.packages.activatePackage('language-php'));
|
waitsForPromise(() => atom.packages.activatePackage('language-php'));
|
||||||
|
|
||||||
runs(function() {
|
runs(() => {
|
||||||
const phpGrammar = atom.grammars.grammarForScopeName('text.html.php');
|
const phpGrammar = atom.grammars.grammarForScopeName('text.html.php');
|
||||||
|
const {tokens} = phpGrammar.tokenizeLine('<?php "/mailto:/" ?>');
|
||||||
|
expect(tokens[3]).toEqual({ value: 'mailto:', scopes: ['text.html.php', 'meta.embedded.line.php', 'source.php', 'string.regexp.double-quoted.php']});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const {tokens} = phpGrammar.tokenizeLine('<?php "/mailto:/" ?>');
|
describe('parsing cfml strings', function () {
|
||||||
expect(tokens[3]).toEqual({value: 'mailto:', scopes: ['text.html.php', 'meta.embedded.line.php', 'source.php', 'string.regexp.double-quoted.php']});});
|
it('does not include anything between (and including) pound signs', function () {
|
||||||
}));
|
|
||||||
|
|
||||||
describe('parsing cfml strings', function() {
|
|
||||||
it('does not include anything between (and including) pound signs', function() {
|
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
const {tokens} = plainGrammar.tokenizeLine('http://github.com/#username#');
|
const {tokens} = plainGrammar.tokenizeLine('http://github.com/#username#');
|
||||||
expect(tokens[0]).toEqual({value: 'http://github.com/', scopes: ['text.plain.null-grammar', 'markup.underline.link.http.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'http://github.com/', scopes: ['text.plain.null-grammar', 'markup.underline.link.http.hyperlink']});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('still includes single pound signs', function() {
|
it('still includes single pound signs', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
const {tokens} = plainGrammar.tokenizeLine('http://github.com/atom/#start-of-content');
|
const {tokens} = plainGrammar.tokenizeLine('http://github.com/atom/#start-of-content');
|
||||||
expect(tokens[0]).toEqual({value: 'http://github.com/atom/#start-of-content', scopes: ['text.plain.null-grammar', 'markup.underline.link.http.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'http://github.com/atom/#start-of-content', scopes: ['text.plain.null-grammar', 'markup.underline.link.http.hyperlink']});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('parsing matching parentheses', function() {
|
describe('parsing matching parentheses', function () {
|
||||||
it('still includes matching parentheses', function() {
|
it('still includes matching parentheses', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
const {tokens} = plainGrammar.tokenizeLine('https://en.wikipedia.org/wiki/Atom_(text_editor)');
|
const {tokens} = plainGrammar.tokenizeLine('https://en.wikipedia.org/wiki/Atom_(text_editor)');
|
||||||
expect(tokens[0]).toEqual({value: 'https://en.wikipedia.org/wiki/Atom_(text_editor)', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
expect(tokens[0]).toEqual({value: 'https://en.wikipedia.org/wiki/Atom_(text_editor)', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not include wrapping parentheses', function() {
|
it('does not include wrapping parentheses', function () {
|
||||||
const plainGrammar = atom.grammars.selectGrammar();
|
const plainGrammar = atom.grammars.selectGrammar();
|
||||||
const {tokens} = plainGrammar.tokenizeLine('(https://en.wikipedia.org/wiki/Atom_(text_editor))');
|
const {tokens} = plainGrammar.tokenizeLine('(https://en.wikipedia.org/wiki/Atom_(text_editor))');
|
||||||
expect(tokens[1]).toEqual({value: 'https://en.wikipedia.org/wiki/Atom_(text_editor)', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
expect(tokens[1]).toEqual({value: 'https://en.wikipedia.org/wiki/Atom_(text_editor)', scopes: ['text.plain.null-grammar', 'markup.underline.link.https.hyperlink']});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
@ -3,6 +3,7 @@ describe('PHP in HTML', () => {
|
|||||||
let grammar = null;
|
let grammar = null;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
atom.config.set('core.useTreeSitterParsers', false);
|
||||||
waitsForPromise(() => atom.packages.activatePackage('language-php'));
|
waitsForPromise(() => atom.packages.activatePackage('language-php'));
|
||||||
|
|
||||||
waitsForPromise(() => // While not used explicitly in any tests, we still activate language-html
|
waitsForPromise(() => // While not used explicitly in any tests, we still activate language-html
|
||||||
|
@ -3,7 +3,10 @@ describe('PHP grammar', function() {
|
|||||||
let grammar = null;
|
let grammar = null;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
waitsForPromise(() => atom.packages.activatePackage('language-php'));
|
atom.config.set('core.useTreeSitterParsers', false);
|
||||||
|
|
||||||
|
waitsForPromise(() =>
|
||||||
|
atom.packages.activatePackage('language-php'));
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
grammar = atom.grammars.grammarForScopeName('source.php');
|
grammar = atom.grammars.grammarForScopeName('source.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user