Don't assume a scalar Map/Set initializer is an integer if its not a string
[hiphop-php.git] / hphp / test / slow / collection_classes / invalid-initializers.php
blobc08472f2870354e735984f0e8619ec4a3f698c9e
1 <?hh // strict
2 // Copyright 2004-present Facebook. All Rights Reserved.
4 function test() {
5 try {
6 echo "Creating Set with booleans...\n";
7 $foo = Set { true, false };
8 echo "Set with booleans succeeded!\n";
9 } catch (InvalidArgumentException $exn) {
10 echo "Set with booleans failed: \"" . $exn->getMessage() . "\"\n";
13 try {
14 echo "Creating Set with floats...\n";
15 $foo = Set { 1.234, 5.6789 };
16 echo "Set with floats succeeded!\n";
17 } catch (InvalidArgumentException $exn) {
18 echo "Set with floats failed: \"" . $exn->getMessage() . "\"\n";
21 try {
22 echo "Creating Map with booleans...\n";
23 $foo = Map { true => 'a', false => 'b' };
24 echo "Map with booleans succeeded!\n";
25 } catch (InvalidArgumentException $exn) {
26 echo "Map with booleans failed: \"" . $exn->getMessage() . "\"\n";
29 try {
30 echo "Creating Map with floats...\n";
31 $foo = Map { 1.234 => 'a', 5.6789 => 'b' };
32 echo "Map with floats succeeded!\n";
33 } catch (InvalidArgumentException $exn) {
34 echo "Map with floats failed: \"" . $exn->getMessage() . "\"\n";
38 test();