FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hack-codegen/test/CodegenBaseTest.php at master · phpsource/hack-codegen · GitHub
phpsource
hack-codegen
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
hack-codegen
/
test
/
CodegenBaseTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (54 loc) · 1.69 KB
Breadcrumbs
hack-codegen
/
test
/
CodegenBaseTest.php
Copy path
File metadata and controls
63 lines (54 loc) · 1.69 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
<
?
hh
//
strict
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
abstract
class
CodegenBaseTest
{
public
static
function
assertTrue
(
bool
$value
,
string
$message
=
'
Expected true
'
,
):
void
{
invariant
(
$value
,
$message
);
}
public
static
function
assertFalse
(
bool
$value
,
string
$message
=
'
Expected false
'
,
):
void
{
invariant
(
!
$value
,
$message
);
}
public
static
function
assertEquals
(
mixed
$expected
,
mixed
$actual
,
?
string
$message
=
null
,
):
void
{
if
(
$message
===
null
) {
$message
=
"
Expected
"
.
print_r
(
$expected
,
true
)
.
"
but got
"
.
print_r
(
$actual
,
true
)
.
"
instead
"
;
}
invariant
(
$expected
===
$actual
,
$message
);
}
public
static
function
assertUnchanged
(
string
$value
,
?
string
$token
=
null
,
):
void
{
$class_name
=
get_called_class
();
$path
=
CodegenExpectedFile
::
getPath(
$class_name
);
$expected
=
CodegenExpectedFile
::
parseFile(
$path
);
$token
=
$token
===
null
?
CodegenExpectedFile
::
findToken() :
$token
;
if
(
$expected
->
contains(
$token
)
&&
$expected
[
$token
]
===
$value
) {
return
;
}
$new_expected
=
clone
$expected
;
$new_expected
[
$token
]
=
$value
;
CodegenExpectedFile
::
writeExpectedFile(
$path
,
$new_expected
,
$expected
);
$expected
=
CodegenExpectedFile
::
parseFile(
$path
);
invariant
(
$expected
->
contains(
$token
)
&&
$expected
[
$token
]
===
$value
,
'
New value not accepted by user
'
,
);
}
}
Back
|
FazBrowse Home
|
New Git URL