Permalink
Browse files

MDL-30494 grade: improved unit tests for tokenize()

  • Loading branch information...
andyjdavis committed Nov 30, 2011
1 parent a5b5881 commit 58800b7c36b9e63bbd01889e15e02e4dfb0e0ad9
Showing with 12 additions and 2 deletions.
  1. +12 −2 grade/grading/simpletest/testlib.php
@@ -153,8 +153,18 @@ public function test_tokenize() {
$needle = '<span>Aha</span>, then who\'s a bad guy here he?';
$tokens = testable_grading_manager::tokenize($needle);
- $this->assertTrue(in_array('span', $tokens));
+ $this->assertEqual(8, count($tokens));
+ $this->assertTrue(in_array('span', $tokens)); // Extracted the tag name
$this->assertTrue(in_array('Aha', $tokens));
- $this->assertTrue(in_array('who', $tokens));
+ $this->assertTrue(in_array('who', $tokens)); // Removed the trailing 's
+ $this->assertTrue(!in_array('a', $tokens)); //Single letter token was dropped
+ $this->assertTrue(in_array('he', $tokens)); // Removed the trailing ?
+
+ $needle = 'grammar, "english language"';
+ $tokens = testable_grading_manager::tokenize($needle);
+ $this->assertTrue(in_array('grammar', $tokens));
+ $this->assertTrue(in_array('english', $tokens));
+ $this->assertTrue(in_array('language', $tokens));
+ $this->assertTrue(!in_array('english language', $tokens)); // Quoting part of the string is not supported
}
}

0 comments on commit 58800b7

Please sign in to comment.