FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpbench/tests/Example/ExpressionLinterTest.php at program-executor · phpbench/phpbench · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
phpbench
/
phpbench
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
133
Star
2k
Code
Issues
28
Pull requests
10
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
phpbench
/
tests
/
Example
/
ExpressionLinterTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (68 loc) · 2.12 KB
Breadcrumbs
phpbench
/
tests
/
Example
/
ExpressionLinterTest.php
Copy path
File metadata and controls
76 lines (68 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace
PhpBench
\
Tests
\
Example
;
use
Generator
;
use
PhpBench
\
Data
\
DataFrame
;
use
PhpBench
\
Expression
\
Ast
\
ComparisonNode
;
use
PhpBench
\
Expression
\
Ast
\
PhpValue
;
use
PhpBench
\
Expression
\
Evaluator
;
use
PhpBench
\
Expression
\
Lexer
;
use
PhpBench
\
Expression
\
Parser
;
use
PhpBench
\
Tests
\
IntegrationTestCase
;
class
ExpressionLinterTest
extends
IntegrationTestCase
{
/**
* @dataProvider provideExpression
*/
public
function
testExpression
(
string
$
filename
):
void
{
$
frame
= DataFrame::
fromRecords
([
[
'
column1
'
=>
'
value1
'
,
'
column2
'
=>
'
value2
'
,
],
[
'
column1
'
=>
'
value3
'
,
'
column2
'
=>
'
value4
'
,
],
]);
/** @phpstan-ignore-next-line */
$
expressions
=
explode
(
"\n"
,
trim
(
file_get_contents
(
$
filename
)));
$
container
=
$
this
->
container
();
foreach
(
$
expressions
as
$
expression
) {
(
function
(
Lexer
$
lexer
,
Parser
$
parser
,
Evaluator
$
evaluator
)
use
(
$
expression
,
$
filename
,
$
frame
):
void
{
$
node
=
$
parser
->
parse
(
$
lexer
->
lex
(
$
expression
));
$
result
=
$
evaluator
->
evaluate
(
$
node
, [
'
data
'
=>
$
frame
]);
if
(!
$
node
instanceof
ComparisonNode) {
return
;
}
if
(!
$
result
instanceof
PhpValue) {
return
;
}
self
::
assertTrue
(
$
result
->
value
(),
sprintf
(
'
%s: %s
'
,
basename
(
$
filename
),
$
expression
));
})(
$
container
->
get
(Lexer::class),
$
container
->
get
(Parser::class),
$
container
->
get
(Evaluator::class)
);
}
$
this
->
addToAssertionCount
(
1
);
}
/**
* @return Generator<mixed>
*/
public
function
provideExpression
():
Generator
{
/** @phpstan-ignore-next-line */
foreach
(
glob
(
__DIR__
.
'
/../../examples/Expression/*
'
)
as
$
file
) {
yield
[
$
file
,
];
}
}
}
Back
|
FazBrowse Home
|
New Git URL