Skip to content

Commit

Permalink
test: add more failing tests
Browse files Browse the repository at this point in the history
These cover some of the cases mentioned at
pulsar-edit#852 (comment)
  • Loading branch information
claytonrcarter committed Jan 10, 2024
1 parent 761ec9d commit 893f684
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/language-php/spec/wasm-tree-sitter-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ describe("Tree-sitter PHP grammar", () => {
})
});

describe('php tags', () => {
it('scopes regular opening tags', async () => {
await editor.setPhpText('');

expect(editor).toHaveScopes([0, 0], '<?php', ['punctuation.section.embedded.begin.php']);
})

it('scopes short opening tags', async () => {
editor.setText('<?= ?>');
await editor.languageMode.ready;

expect(editor).toHaveScopes([0, 0], '<?=', ['punctuation.section.embedded.begin.php']);
})

it('scopes closing tags', async () => {
await editor.setPhpText('?>');

expect(editor).toHaveScopes([1, 0], '?>', ['punctuation.section.embedded.end.php']);
})
});

describe("operators", () => {
it("scopes =", async () => {
await editor.setPhpText('$test = 1;');
Expand Down Expand Up @@ -144,6 +165,21 @@ describe("Tree-sitter PHP grammar", () => {
expect(editor).toHaveScopes([1, 0], 'final', ["keyword.control.final.php"]);
expect(editor).toHaveScopes([1, 6], 'class', ["storage.type.class.php"]);
});

describe('properties', () => {
it('scopes readonly properties', async () => {
await editor.setPhpText(`
class Test {
public readonly int $a;
}`)

expect(editor).toHaveScopes([1, 0], 'class', ['storage.type.TYPE.php'])
expect(editor).toHaveScopes([2, 2], 'public', ['storage.modifier.public.php'])
expect(editor).toHaveScopes([2, 9], 'readonly', ['storage.modifier.readonly.php'])
expect(editor).toHaveScopes([2, 18], 'int', ['storage.type.builtin.php'])
})

})
});

describe("phpdoc", () => {
Expand Down

0 comments on commit 893f684

Please sign in to comment.