Update PhutilCowsay.php to work for small cows.
In doing so, we also simplify the code to just use multiline regexps rather than trying to parse a line at a time.
Differential D25436
Update PhutilCowsay.php to work for small cows Sten on Sep 12 2023, 16:09. Authored by Tags None Referenced Files
Subscribers Tokens
Details
Update PhutilCowsay.php to work for small cows. In doing so, we also simplify the code to just use multiline regexps rather than trying to parse a line at a time. ________________
< What about me? >
----------------
\ ,__,
\ (oo)____
(__) )\
||--|| * Check cowsay works for the built in non-perl cow: cowsay(cow='companion'){{{Built in}}} Test all the perl cows: cowsay(cow='bunny'){{{Testing bunny}}} cowsay(cow='cower'){{{Testing cower}}} cowsay(cow='daemon'){{{Testing daemon}}} cowsay(cow='default'){{{Testing default}}} cowsay(cow='dragon-and-cow'){{{Testing dragon-and-cow}}} cowsay(cow='dragon'){{{Testing dragon}}} cowsay(cow='elephant'){{{Testing elephant}}} cowsay(cow='eyes'){{{Testing eyes}}} cowsay(cow='flaming-sheep'){{{Testing flaming-sheep}}} cowsay(cow='head-in'){{{Testing head-in}}} cowsay(cow='kitty'){{{Testing kitty}}} cowsay(cow='koala'){{{Testing koala}}} cowsay(cow='meow'){{{Testing meow}}} cowsay(cow='moofasa'){{{Testing moofasa}}} cowsay(cow='moose'){{{Testing moose}}} cowsay(cow='mutilated'){{{Testing mutilated}}} cowsay(cow='satanic'){{{Testing satanic}}} cowsay(cow='sheep'){{{Testing sheep}}} cowsay(cow='skeleton'){{{Testing skeleton}}} cowsay(cow='small'){{{Testing small}}} cowsay(cow='squirrel'){{{Testing squirrel}}} cowsay(cow='stegosaurus'){{{Testing stegosaurus}}} cowsay(cow='supermilker'){{{Testing supermilker}}} cowsay(cow='surgery'){{{Testing surgery}}} cowsay(cow='turkey'){{{Testing turkey}}} cowsay(cow='turtle'){{{Testing turtle}}} cowsay(cow='tux'){{{Testing tux}}} cowsay(cow='www'){{{Testing www}}}
Diff Detail
Event Timeline
Comment Actions I'm trying to propose two unit tests, but I'm not able to make them "fail" before the change. The unit always says "OK" so I think I'm not useful :( But here as reference: src/utils/__tests__/cowsay/small.expect ________________ < What about me? > ---------------- \ ,__, \ (oo)____ (__) )\ ||--|| * src/utils/__tests__/cowsay/small.test $thoughts ,__, $thoughts ($eyes)____ (__) )\ ||--|| * ~~~~~~~~~~ { "text": "What about me?" } I'm just using against: arc unit src/utils/__tests__/PhutilCowsayTestCase.php Before and after this change. Any idea why is that unit test always resulting "OK" to me? Anyway, feel free to adapt and pull this inside your change 👍 Comment Actions smallcow test case added. Test fails under the previous code with: $ arc unit FAIL PhutilCowsayTestCase::testCowsay Assertion failed, expected values to be equal (at PhutilCowsayTestCase.php:57): Cowsay Test Case "small.test" Expected vs Actual Output Diff --- Old Value +++ New Value @@ -1,7 +1,8 @@ ' __________________ < How are my eyes? > ------------------ +oo = ".." unless (oo); \ ,__, \ (oo)____ (__) )\ ||--|| *' Turns out we can simply copy the perl template file, then add in the seperator and test values. Comment Actions I'm a bit confused (!) I thought there were no PHP changes on Rev 1414 and I approved it, but instead I now see that we have again PHP changes. It's unclear to me whenever the Diff I approved was "updated to reflect changes", or maybe I'm just totally crazy because of real life. Please share your opinion. In any case, thanks, and: |