Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for various already implemented features
Summary: This diff just adds tests for various specifications that are already implemented in the base revision. Reviewed By: dlreeves Differential Revision: D6764209 fbshipit-source-id: 0d325cdc7784c408332afa459ee940cb6407bc9e
- Loading branch information
Showing
12 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
<?hh // strict | |||
|
|||
function testAssign(dynamic $x, dynamic $y): void { | |||
$x += 5; // $x is now a num | |||
hh_show($x); | |||
$y .= "string"; // $y is now a string | |||
hh_show($y); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
File "assignment.php", line 5, characters 3-13: | |||
num | |||
File "assignment.php", line 7, characters 3-13: | |||
string | |||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<?hh // strict | |||
|
|||
function testBools(dynamic $x): void { | |||
$y = $x && true; // $y : bool | |||
hh_show($y); | |||
$y = $x || false; // $y : bool | |||
hh_show($y); | |||
$y = !$x; // $y : bool | |||
hh_show($y); | |||
$y = $x === 5; // $y : bool | |||
hh_show($y); | |||
$y = $x == 5; // $y : bool | |||
hh_show($y); | |||
if ($x) // valid, no sketchy null check warning | |||
{ | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
File "booleans.php", line 5, characters 3-13: | |||
bool | |||
File "booleans.php", line 7, characters 3-13: | |||
bool | |||
File "booleans.php", line 9, characters 3-13: | |||
bool | |||
File "booleans.php", line 11, characters 3-13: | |||
bool | |||
File "booleans.php", line 13, characters 3-13: | |||
bool | |||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
<?hh // strict | |||
|
|||
function testClassName(classname<dynamic> $x): void { | |||
$y = $x::staticMeth(); // $y : dynamic | |||
hh_show($y); | |||
$y = $x::staticProp; // $y : dynamic | |||
hh_show($y); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
File "classname.php", line 5, characters 3-13: | |||
dynamic | |||
File "classname.php", line 7, characters 3-13: | |||
dynamic | |||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<?hh // strict | |||
|
|||
function testCollections(dynamic $x): void { | |||
$y = vec[]; | |||
$y[] = 5; // $y : vec<int> | |||
hh_show($y); | |||
$y[] = $x; // $y : vec<(int | dynamic)> | |||
hh_show($y); | |||
$y = Vector { $x }; // $y : Vector<dynamic> | |||
hh_show($y); | |||
$y = Map { 5 => $x }; // $y : Map<int, dynamic> | |||
hh_show($y); | |||
} | |||
|
|||
function testCollections2(vec<int> $a, dynamic $x): void { | |||
$a[] = $x; // error, $a is of type vec<int>, incompatible with dynamic | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
File "collections.php", line 6, characters 3-13: | |||
vec<^(int)> | |||
File "collections.php", line 8, characters 3-13: | |||
vec<^(int | dynamic)> | |||
File "collections.php", line 10, characters 3-13: | |||
Vector<^(dynamic)> | |||
File "collections.php", line 12, characters 3-13: | |||
Map<^(int), ^(dynamic)> | |||
File "collections.php", line 16, characters 3-11: | |||
Invalid assignment (Typing[4110]) | |||
File "collections.php", line 15, characters 31-33: | |||
This is an int | |||
File "collections.php", line 15, characters 40-46: | |||
It is incompatible with a dynamic value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
<?hh // strict | |||
|
|||
function testObjGet(dynamic $x): void { | |||
$y = $x::staticProp; // $y : dynamic | |||
hh_show($y); | |||
$y = $x->property; // $y : dynamic | |||
hh_show($y); | |||
$x->property = 7; | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
File "obj_get.php", line 5, characters 3-13: | |||
dynamic | |||
File "obj_get.php", line 7, characters 3-13: | |||
dynamic | |||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
<?hh // strict | |||
|
|||
function testString(dynamic $x): void { | |||
$y = $x."hello"; // $y : string | |||
hh_show($y); | |||
$y = $x.$x; // $y : string | |||
hh_show($y); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
File "string_concat.php", line 5, characters 3-13: | |||
string | |||
File "string_concat.php", line 7, characters 3-13: | |||
string | |||
No errors |