From ba15ed9c688867dab90b5680a0b4dd904f94a2e5 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Thu, 21 Jul 2022 16:31:22 +0900 Subject: [PATCH] add test example --- .../react/expected/optionalPropValue.res.txt | 32 +++++++++++++++++++ tests/ppx/react/optionalPropValue.res | 18 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/ppx/react/expected/optionalPropValue.res.txt create mode 100644 tests/ppx/react/optionalPropValue.res diff --git a/tests/ppx/react/expected/optionalPropValue.res.txt b/tests/ppx/react/expected/optionalPropValue.res.txt new file mode 100644 index 00000000..6587b7fb --- /dev/null +++ b/tests/ppx/react/expected/optionalPropValue.res.txt @@ -0,0 +1,32 @@ +module Parens = { + type props<'id> = {key?: string, id?: 'id} + @react.component + let make = ({?id, _}: props<'id>) => { + ReactDOM.jsx( + "div", + { + id: ?{ + let _ = () + id->Option.map(x => x) + }, + }, + ) + } + let make = { + let \"OptionalPropValue$Parens" = (props: props<_>) => make(props) + \"OptionalPropValue$Parens" + } +} + +module WithoutParens = { + type props<'id> = {key?: string, id?: 'id} + + @react.component + let make = ({?id, _}: props<'id>) => { + ReactDOM.jsx("div", {id: ?id->Option.map(x => x)}) + } + let make = { + let \"OptionalPropValue$WithoutParens" = (props: props<_>) => make(props) + \"OptionalPropValue$WithoutParens" + } +} diff --git a/tests/ppx/react/optionalPropValue.res b/tests/ppx/react/optionalPropValue.res new file mode 100644 index 00000000..5ad053f5 --- /dev/null +++ b/tests/ppx/react/optionalPropValue.res @@ -0,0 +1,18 @@ +module Parens = { + @react.component + let make = (~id=?) => { +
Option.map(x => x) + } + /> + } +} + +module WithoutParens = { + @react.component + let make = (~id=?) => { +
Option.map(x => x)} /> + } +}