From 1444231337a784f752f7b671968e710b644d8865 Mon Sep 17 00:00:00 2001 From: tswicegood Date: Sat, 28 Jun 2008 22:10:44 +0000 Subject: [PATCH] fix issue with windows EOL causing issues on regular expression (fixes #72) git-svn-id: https://svn.phpt.info/Core/trunk@707 54d25d7b-d40e-47af-a99d-8d4037bc02b6 --- src/PHPT/Section/EXPECTREGEX.php | 2 ++ .../can-handle-Windows-EOL-markers.phpt | 29 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/Section/Expectregex/can-handle-Windows-EOL-markers.phpt diff --git a/src/PHPT/Section/EXPECTREGEX.php b/src/PHPT/Section/EXPECTREGEX.php index 5907c4b..e129389 100644 --- a/src/PHPT/Section/EXPECTREGEX.php +++ b/src/PHPT/Section/EXPECTREGEX.php @@ -11,6 +11,8 @@ class PHPT_Section_EXPECTREGEX extends PHPT_Section_ExpectationAbstract } if ($pattern[0] != '/') { $pattern = '/' . trim($pattern) . '/'; + } else { + $pattern = trim($pattern); } // capture $matches - it'll still be NULL if $pattern was invalid diff --git a/tests/Section/Expectregex/can-handle-Windows-EOL-markers.phpt b/tests/Section/Expectregex/can-handle-Windows-EOL-markers.phpt new file mode 100644 index 0000000..da71a2a --- /dev/null +++ b/tests/Section/Expectregex/can-handle-Windows-EOL-markers.phpt @@ -0,0 +1,29 @@ +--TEST-- +PHPT_Section_EXPECTREGEX can handle regular expressions that have Windows +EOL markers on them. +--FILE-- +output = 'foobar' . rand(100, 200); + +$data = "/.*foobar[12][0-9]{2}.*/\r\n===DONE==="; +$section = new PHPT_Section_EXPECTREGEX($data); +try { + $section->run($case); + trigger_error('exception not caught'); +} catch (PHPT_Case_FailureException $e) { + +} + +$case->output = 'foobar' . rand(100, 200) . "\r\n===DONE==="; +$section->run($case); + +?> +===DONE=== +--EXPECT-- +===DONE=== + -- 2.11.4.GIT