Skip to content

Commit 70d9ccd

Browse files
committed
Add test cases for PHP 8.0 Attributes
1 parent 44d2924 commit 70d9ccd

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

tests/8.0/attribute/class.php.faces

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
;; -*- mode: emacs-lisp -*-
2+
(("<?php" . php-php-tag)
3+
("
4+
5+
")
6+
("# " . font-lock-comment-delimiter-face)
7+
("Comment
8+
" . font-lock-comment-face)
9+
("
10+
#[ExampleAttribute]
11+
#[Attr1, Attr2]
12+
")
13+
("class" . php-class-declaration)
14+
(" ")
15+
("Klass" . font-lock-type-face)
16+
("
17+
{
18+
#[ExampleAttribute]
19+
")
20+
("function" . php-keyword)
21+
(" ")
22+
("f1" . php-function-name)
23+
("() { }
24+
25+
#[WithoutArgument]
26+
#[")
27+
("SingleArgument" . php-function-call)
28+
("(0)]
29+
#[")
30+
("FewArguments" . php-function-call)
31+
("(")
32+
("'Hello'" . php-string)
33+
(", ")
34+
("'World'" . php-string)
35+
(")]
36+
")
37+
("function" . php-keyword)
38+
(" ")
39+
("foo" . php-function-name)
40+
("() {}
41+
42+
#[WithoutArgument] #[")
43+
("SingleArgument" . php-function-call)
44+
("(0)] #[")
45+
("FewArguments" . php-function-call)
46+
("(")
47+
("'Hello'" . php-string)
48+
(", ")
49+
("'World'" . php-string)
50+
(")]
51+
")
52+
("function" . php-keyword)
53+
(" ")
54+
("bar" . php-function-name)
55+
("() {}
56+
57+
#[")
58+
("Attr2" . php-function-call)
59+
("(")
60+
("\"foo\"" . php-string)
61+
("), ")
62+
("Attr2" . php-function-call)
63+
("(")
64+
("\"bar\"" . php-string)
65+
(")]
66+
")
67+
("function" . php-keyword)
68+
(" ")
69+
("buz" . php-function-name)
70+
("() {}
71+
}
72+
"))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
;; -*- mode: emacs-lisp -*-
2+
(("<?php" . php-php-tag)
3+
("
4+
5+
#[ExampleAttribute]
6+
")
7+
("function" . php-keyword)
8+
(" ")
9+
("f1" . php-function-name)
10+
("() { }
11+
12+
#[WithoutArgument]
13+
#[")
14+
("SingleArgument" . php-function-call)
15+
("(0)]
16+
#[")
17+
("FewArguments" . php-function-call)
18+
("(")
19+
("'Hello'" . php-string)
20+
(", ")
21+
("'World'" . php-string)
22+
(")]
23+
")
24+
("function" . php-keyword)
25+
(" ")
26+
("foo" . php-function-name)
27+
("() {}
28+
29+
#[WithoutArgument]#[")
30+
("SingleArgument" . php-function-call)
31+
("(0)]#[")
32+
("FewArguments" . php-function-call)
33+
("(")
34+
("'Hello'" . php-string)
35+
(", ")
36+
("'World'" . php-string)
37+
(")]
38+
")
39+
("function" . php-keyword)
40+
(" ")
41+
("bar" . php-function-name)
42+
("() {}
43+
"))

tests/8.0/attribute/function2.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
#[
4+
Deprecated
5+
]
6+
function f($arg1,
7+
#[Deprecated] $arg2){}
8+
#Deprecated
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
;; -*- mode: emacs-lisp -*-
2+
(("<?php" . php-php-tag)
3+
("
4+
5+
#[
6+
Deprecated
7+
]
8+
")
9+
("function" . php-keyword)
10+
(" ")
11+
("f" . php-function-name)
12+
("(")
13+
("$" . php-variable-sigil)
14+
("arg1" . php-variable-name)
15+
(",
16+
#[Deprecated] ")
17+
("$" . php-variable-sigil)
18+
("arg2" . php-variable-name)
19+
("){}
20+
")
21+
("#D" . font-lock-comment-delimiter-face)
22+
("eprecated
23+
" . font-lock-comment-face))

tests/php-mode-test.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,12 @@ Meant for `php-mode-test-issue-503'."
654654
(with-php-mode-test ("7.4/arrow-function.php" :faces t))
655655
(with-php-mode-test ("7.4/typed-property.php" :faces t)))
656656

657+
(ert-deftest php-mode-test-php80 ()
658+
"Test highlighting language constructs added in PHP 8.0."
659+
(with-php-mode-test ("8.0/attribute/class.php" :faces t))
660+
(with-php-mode-test ("8.0/attribute/function.php" :faces t))
661+
(with-php-mode-test ("8.0/attribute/function2.php" :faces t)))
662+
657663
(ert-deftest php-mode-test-php81 ()
658664
"Test highlighting language constructs added in PHP 8.1."
659665
(with-php-mode-test ("8.1/enum.php" :faces t)))

0 commit comments

Comments
 (0)