Skip to content

Commit 3b13c27

Browse files
Port the open-xhp-specification tests
1 parent ca02719 commit 3b13c27

File tree

55 files changed

+1138
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1138
-6
lines changed

tests/BugsInFlowTest.hack

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function bugs_in_flow_test(TestChain\Chain $chain)[]: TestChain\Chain {
1111
return $chain->group(__FUNCTION__)
1212
->test(
1313
'test_exclamation_const_flow_can_be_constructed_with_variables',
14-
()[defaults]: void ==> {
14+
(): void ==> {
1515
$flow = ExclamationConstFlow::createWithConstantsAndVariables(
1616
dict['!const' => 'c'],
1717
dict['var' => 'v'],
@@ -23,7 +23,7 @@ function bugs_in_flow_test(TestChain\Chain $chain)[]: TestChain\Chain {
2323

2424
->test(
2525
'test_first_come_first_served_flow_can_getx_a_null_constant',
26-
()[defaults]: void ==> {
26+
(): void ==> {
2727
$flow = FirstComeFirstServedFlow::createWithConstantsAndVariables(
2828
dict['nullable' => null],
2929
dict[],
@@ -34,7 +34,7 @@ function bugs_in_flow_test(TestChain\Chain $chain)[]: TestChain\Chain {
3434

3535
->test(
3636
'test_first_come_first_served_flow_does_not_permit_constant_overriding_in_the_constructor',
37-
()[defaults]: void ==> {
37+
(): void ==> {
3838
expect_invoked(
3939
() ==> FirstComeFirstServedFlow::createWithConstantsAndVariables(
4040
dict['one' => true],
@@ -46,7 +46,7 @@ function bugs_in_flow_test(TestChain\Chain $chain)[]: TestChain\Chain {
4646

4747
->test(
4848
'test_first_come_first_served_flow_declare_constant_exception_mentions_the_correct_storage_type',
49-
()[defaults]: void ==> {
49+
()[write_props]: void ==> {
5050
$flow = FirstComeFirstServedFlow::createWithConstantsAndVariables(
5151
dict['const' => true],
5252
dict['var' => false],
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_defaulted_set_attribute_to_valid_target_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_the_explicitly_set_value_is_spread', () ==> {
13+
$type_under_test =
14+
<herp_and_derp {...<herp_defaulted herp="not-default" />} />;
15+
expect(get_attributes($type_under_test))->toEqual(
16+
tuple(dict['herp' => 'not-default'], dict[]),
17+
);
18+
});
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_defaulted_unset_attribute_to_valid_target_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_the_default_value_is_spread', () ==> {
13+
$type_under_test = <herp_and_derp {...<herp_defaulted />} />;
14+
expect(get_attributes($type_under_test))->toEqual(
15+
tuple(dict['herp' => 'default'], dict[]),
16+
);
17+
});
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_defaulted_unset_attribute_with_null_to_valid_target_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test(
13+
'test_the_null_value_is_not_copied_in_the_spread',
14+
() ==> {
15+
$type_under_test =
16+
<herp_and_derp herp="not-null" {...<herp_defaulted_with_null />} />;
17+
expect(get_attributes($type_under_test))->toEqual(
18+
tuple(dict['herp' => 'not-null'], dict[]),
19+
);
20+
},
21+
);
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_to_a_tag_with_a_subset_of_the_declared_attributes_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_only_the_common_attributes_are_spread', () ==> {
13+
$type_under_test =
14+
<herp_and_derp {...<herp_and_durr herp="h" durr={5.5} />} />;
15+
expect(get_attributes($type_under_test))->toEqual(
16+
tuple(dict['herp' => 'h'], dict[]),
17+
);
18+
});
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_to_a_tag_with_identical_declared_attributes_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_attributes_are_spread', () ==> {
13+
$type_under_test =
14+
<herp_and_derp {...<herp_and_derp herp="h" derp={5.5} />} />;
15+
expect(get_attributes($type_under_test))->toEqual(
16+
tuple(dict['herp' => 'h', 'derp' => 5.5], dict[]),
17+
);
18+
});
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_to_a_tag_with_the_same_attribute_specified_as_null_in_the_xhp_open_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_the_explicit_null_value_is_overridden_by_the_spread', ()[
13+
defaults,
14+
] ==> {
15+
$type_under_test =
16+
<herp_and_derp herp={null} {...<herp_and_derp herp="from-spread" />} />;
17+
expect(get_attributes($type_under_test))->toEqual(
18+
tuple(dict['herp' => 'from-spread'], dict[]),
19+
);
20+
})
21+
->test(
22+
'test_the_explicit_null_value_passed_after_the_spread_overrides_the_value_from_the_spread',
23+
() ==> {
24+
$type_under_test =
25+
<herp_and_derp
26+
{...<herp_and_derp herp="from-spread" />}
27+
herp={null}
28+
/>;
29+
expect($type_under_test->:herp)->toEqual(null);
30+
},
31+
);
32+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_to_a_tag_with_the_same_attribute_specified_in_the_xhp_open_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test(
13+
'test_the_common_values_set_before_the_spread_are_overridden',
14+
() ==> {
15+
$type_under_test =
16+
<herp_and_derp
17+
herp="from-before-spread"
18+
{...<herp_and_derp herp="from-spread" />}
19+
/>;
20+
expect(get_attributes($type_under_test))->toEqual(
21+
tuple(dict['herp' => 'from-spread'], dict[]),
22+
);
23+
},
24+
)
25+
->test(
26+
'test_the_common_values_set_after_the_spread_override_the_spread',
27+
() ==> {
28+
$type_under_test =
29+
<herp_and_derp
30+
{...<herp_and_derp herp="from-spread" />}
31+
herp="from-after-spread"
32+
/>;
33+
expect(get_attributes($type_under_test))->toEqual(
34+
tuple(dict['herp' => 'from-after-spread'], dict[]),
35+
);
36+
},
37+
);
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_to_a_tag_without_declared_attributes_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_attributes_are_not_spread', () ==> {
13+
$type_under_test = <empty {...<herp_and_derp herp="h" derp={5.5} />} />;
14+
expect(get_attributes($type_under_test))->toEqual(tuple(dict[], dict[]));
15+
});
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** sgml-stream is MIT licensed, see /LICENSE. */
2+
namespace HTL\SGMLStream\Tests;
3+
4+
use namespace HTL\TestChain;
5+
use function HTL\Expect\expect;
6+
7+
<<TestChain\Discover>>
8+
function given_a_spread_of_declared_set_attribute_with_null_to_valid_target_test(
9+
TestChain\Chain $chain,
10+
)[]: TestChain\Chain {
11+
return $chain->group(__FUNCTION__)
12+
->test('test_the_null_value_is_not_copied_in_the_spread', () ==> {
13+
$type_under_test =
14+
<herp_and_derp herp="not-null" {...<herp_and_derp herp={null} />} />;
15+
expect(get_attributes($type_under_test))->toEqual(
16+
tuple(dict['herp' => 'not-null'], dict[]),
17+
);
18+
});
19+
}

0 commit comments

Comments
 (0)