From 7cf9c6571e16b5ee786f1a1ee1fd15101c2956fc Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Wed, 7 Sep 2022 19:37:13 -0700 Subject: [PATCH] add an if-expression twist --- .../pmd/lang/lua/cpd/testdata/luauTypes.lua | 2 +- .../pmd/lang/lua/cpd/testdata/luauTypes.txt | 33 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.lua b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.lua index 2294030324..6afb9b7c56 100644 --- a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.lua +++ b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.lua @@ -26,5 +26,5 @@ return function (req, ...: boolean): ({[string|number]: T}, string, Function< res[#res - 2] = { ... } end - return (res :: any) :: { T }, body, function(...): ...any return ... end + return (res :: any) :: { T }, (if req then body else "") :: string, function(...): ...any return ... end end \ No newline at end of file diff --git a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt index 7eb53efa9e..1517afea84 100644 --- a/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt +++ b/pmd-lua/src/test/resources/net/sourceforge/pmd/lang/lua/cpd/testdata/luauTypes.txt @@ -271,18 +271,27 @@ L29 [T] 28 28 [}] 30 30 [,] 31 31 - [body] 33 36 - [,] 37 37 - [function] 39 46 - [(] 47 47 - [...] 48 50 - [)] 51 51 - [:] 52 52 - [...] 54 56 - [any] 57 59 - [return] 61 66 - [...] 68 70 - [end] 72 74 + [(] 33 33 + [if] 34 35 + [req] 37 39 + [then] 41 44 + [body] 46 49 + [else] 51 54 + [""] 56 57 + [)] 58 58 + [::] 60 61 + [string] 63 68 + [,] 69 69 + [function] 71 78 + [(] 79 79 + [...] 80 82 + [)] 83 83 + [:] 84 84 + [...] 86 88 + [any] 89 91 + [return] 93 98 + [...] 100 102 + [end] 104 106 L30 [end] 1 3 EOF