Skip to content

Commit

Permalink
fix issue with windows EOL causing issues on regular expression (fixe…
Browse files Browse the repository at this point in the history
…s #72)

git-svn-id: https://svn.domain51.com/test/Core/trunk@707 54d25d7b-d40e-47af-a99d-8d4037bc02b6
  • Loading branch information
tswicegood committed Jun 28, 2008
1 parent b0de6ff commit edd2031
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/PHPT/Section/EXPECTREGEX.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ protected function _isValid(PHPT_Case $case)
}
if ($pattern[0] != '/') {
$pattern = '/' . trim($pattern) . '/';
} else {
$pattern = trim($pattern);
}

// capture $matches - it'll still be NULL if $pattern was invalid
Expand Down
29 changes: 29 additions & 0 deletions tests/Section/Expectregex/can-handle-Windows-EOL-markers.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
PHPT_Section_EXPECTREGEX can handle regular expressions that have Windows
EOL markers on them.
--FILE--
<?php

require_once dirname(__FILE__) . '/../../_setup.inc';
require_once dirname(__FILE__) . '/../_simple-test-case.inc';

$case = new PHPT_SimpleTestCase();
$case->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===

0 comments on commit edd2031

Please sign in to comment.