summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2011-07-23 20:23:21 +0000
committerPierre Joye <pajoye@php.net>2011-07-23 20:23:21 +0000
commit80496c9dc46cabf7185e09d1a3e65b084e4d9fc0 (patch)
treeb8eeaa5d12e514825a10e48d705a8c0f5f8c7345 /tests
parent1fc4bc1d569864279058e40bdea8a47a51187da3 (diff)
downloadphp-git-80496c9dc46cabf7185e09d1a3e65b084e4d9fc0.tar.gz
- add short array syntax as defined in https://wiki.php.net/rfc/shortsyntaxforarrays, 2nd solution using => only
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/array_shortcut_001.phpt13
-rw-r--r--tests/lang/array_shortcut_002.phpt13
-rw-r--r--tests/lang/array_shortcut_003.phpt13
-rw-r--r--tests/lang/array_shortcut_005.phpt20
4 files changed, 59 insertions, 0 deletions
diff --git a/tests/lang/array_shortcut_001.phpt b/tests/lang/array_shortcut_001.phpt
new file mode 100644
index 0000000000..18a10ea09b
--- /dev/null
+++ b/tests/lang/array_shortcut_001.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Square bracket array shortcut test
+--FILE--
+<?php
+print_r([1, 2, 3]);
+?>
+--EXPECT--
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 3
+)
diff --git a/tests/lang/array_shortcut_002.phpt b/tests/lang/array_shortcut_002.phpt
new file mode 100644
index 0000000000..25aee9ba39
--- /dev/null
+++ b/tests/lang/array_shortcut_002.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Square bracket associative array shortcut test
+--FILE--
+<?php
+print_r(["foo" => "orange", "bar" => "apple", "baz" => "lemon"]);
+?>
+--EXPECT--
+Array
+(
+ [foo] => orange
+ [bar] => apple
+ [baz] => lemon
+)
diff --git a/tests/lang/array_shortcut_003.phpt b/tests/lang/array_shortcut_003.phpt
new file mode 100644
index 0000000000..75e428b63e
--- /dev/null
+++ b/tests/lang/array_shortcut_003.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Testing array shortcut and bracket operator
+--FILE--
+<?php
+$a = [1, 2, 3, 4, 5];
+print_r([$a[1], $a[3]]);
+?>
+--EXPECT--
+Array
+(
+ [0] => 2
+ [1] => 4
+)
diff --git a/tests/lang/array_shortcut_005.phpt b/tests/lang/array_shortcut_005.phpt
new file mode 100644
index 0000000000..7cc7386f83
--- /dev/null
+++ b/tests/lang/array_shortcut_005.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Testing nested array shortcut
+--FILE--
+<?php
+print_r([1, 2, 3, ["foo" => "orange", "bar" => "apple", "baz" => "lemon"]]);
+?>
+--EXPECT--
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 3
+ [3] => Array
+ (
+ [foo] => orange
+ [bar] => apple
+ [baz] => lemon
+ )
+
+)