From 5258201032ad864a9d810d50d00aa88e621ece75 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 17 Sep 2021 13:24:18 -0700 Subject: [PATCH] Add HHVM runtime tests for XHP with expression trees Differential Revision: D30530851 fbshipit-source-id: 862d630dfbb06b9624d876157619f6471e924451 --- .../test/slow/expression_trees/expression_tree.inc | 23 ++++++++++++++++++++++ hphp/test/slow/expression_trees/xhp.php | 22 +++++++++++++++++++++ hphp/test/slow/expression_trees/xhp.php.expect | 6 ++++++ hphp/test/slow/expression_trees/xhp.php.hphp_opts | 1 + hphp/test/slow/expression_trees/xhp.php.opts | 1 + 5 files changed, 53 insertions(+) create mode 100644 hphp/test/slow/expression_trees/xhp.php create mode 100644 hphp/test/slow/expression_trees/xhp.php.expect create mode 100644 hphp/test/slow/expression_trees/xhp.php.hphp_opts create mode 100644 hphp/test/slow/expression_trees/xhp.php.opts diff --git a/hphp/test/slow/expression_trees/expression_tree.inc b/hphp/test/slow/expression_trees/expression_tree.inc index 1e9fc3e5c03..e96a33828b6 100644 --- a/hphp/test/slow/expression_trees/expression_tree.inc +++ b/hphp/test/slow/expression_trees/expression_tree.inc @@ -193,6 +193,29 @@ class Code { return "continue;"; } + public function visitXhp( + ?ExprPos $_, + string $class_name, + dict $attrs, + vec $children, + ): Code::TAst { + $attr_parts = vec[]; + foreach ($attrs as $name => $value) { + $attr_parts[] = $name."=".$value; + } + $attr_string = implode(" ", $attr_parts); + + return "<". + $class_name. + " ". + $attr_string. + ">\n". + concat_block($children). + "\n"; + } + // Splice public function splice( ?ExprPos $_, diff --git a/hphp/test/slow/expression_trees/xhp.php b/hphp/test/slow/expression_trees/xhp.php new file mode 100644 index 00000000000..5248dfbfeb7 --- /dev/null +++ b/hphp/test/slow/expression_trees/xhp.php @@ -0,0 +1,22 @@ +> + +class :my-tag { + attribute mixed x; + public function __construct( + dict $attrs, + vec $children, + string $file, + int $line, + ) {} +} + +<<__EntryPoint>> +function test(): void { + require 'expression_tree.inc'; + + $et = Code`foo `; + + print_et($et); +} diff --git a/hphp/test/slow/expression_trees/xhp.php.expect b/hphp/test/slow/expression_trees/xhp.php.expect new file mode 100644 index 00000000000..142cd245bac --- /dev/null +++ b/hphp/test/slow/expression_trees/xhp.php.expect @@ -0,0 +1,6 @@ + +"foo " + + + + diff --git a/hphp/test/slow/expression_trees/xhp.php.hphp_opts b/hphp/test/slow/expression_trees/xhp.php.hphp_opts new file mode 100644 index 00000000000..027f3ed6b13 --- /dev/null +++ b/hphp/test/slow/expression_trees/xhp.php.hphp_opts @@ -0,0 +1 @@ +-vRuntime.Hack.Lang.AllowUnstableFeatures=1 diff --git a/hphp/test/slow/expression_trees/xhp.php.opts b/hphp/test/slow/expression_trees/xhp.php.opts new file mode 100644 index 00000000000..1f2bf3d6621 --- /dev/null +++ b/hphp/test/slow/expression_trees/xhp.php.opts @@ -0,0 +1 @@ +-vHack.Lang.AllowUnstableFeatures=1 -- 2.11.4.GIT