103 linhas
3.4 KiB
PHP
Arquivo Executável
103 linhas
3.4 KiB
PHP
Arquivo Executável
<?php
|
|
require(dirname(__FILE__) . '/../../../../../Tests/config.php');
|
|
|
|
/**
|
|
* Test class for Tokenizer.
|
|
* Generated by PHPUnit on 2011-02-21 at 11:46:35.
|
|
*/
|
|
class TokenizerTest extends PHPUnit_Framework_TestCase {
|
|
|
|
/**
|
|
* @var Tokenizer
|
|
*/
|
|
protected $object;
|
|
|
|
protected $idiom= 'en';
|
|
|
|
|
|
/**
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
* This method is called before a test is executed.
|
|
*/
|
|
protected function setUp() {
|
|
$this->setIdiom();
|
|
}
|
|
|
|
public function setIdiom($idiom='en')
|
|
{
|
|
Mind::$currentProject['idiom']= $idiom;
|
|
Mind::$langPath= dirname(__FILE__) . '/../../../../../mind3rd/API/languages/';
|
|
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/IgnoreForms.php';
|
|
require_once dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/Verbalizer.php';
|
|
Tokenizer::loadModifiers(dirname(__FILE__) . '/../../../../../mind3rd/API/languages/'.$idiom.'/');
|
|
$this->object = new Tokenizer;
|
|
}
|
|
|
|
/**
|
|
* Tears down the fixture, for example, closes a network connection.
|
|
* This method is called after a test is executed.
|
|
*/
|
|
protected function tearDown() {
|
|
|
|
}
|
|
|
|
// these are the tests in Portuguese, that's why we're setting
|
|
// the idiom to PT in the first line on each test
|
|
public function testSweep1() {
|
|
$this->setIdiom('pt');
|
|
$ar= Array('cada','professor','dever', 'ter', 'um','ou','muitos','aluno','.');
|
|
$exp= Array(-4, 2, 64, 1, 8, 16, 32, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep2() {
|
|
$this->setIdiom('pt');
|
|
$ar= Array('professor', 'ter', 'um','aluno','.');
|
|
$exp= Array(2, 1, 8, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep3() {
|
|
$this->setIdiom('pt');
|
|
$ar= Array('professor', 'poder', 'ter', 'um','aluno','.');
|
|
$exp= Array(2, 128, 1, 8, 2, -2);
|
|
$this->assertEquals($exp, $this->object->sweep($ar));
|
|
}
|
|
public function testSweep4() {
|
|
$this->setIdiom('pt');
|
|
$ar= Array('professor', 'poder', 'ter', 'um', 'ou', 'muitos','aluno','.');
|
|
$exp= Array(2, Token::MT_QMAY, 1, 8, Token::MT_OR, Token::MT_MANY, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep5() {
|
|
$this->setIdiom('pt');
|
|
$ar= Array('cada','professor','dever', 'ter', 'muitos','aluno','.');
|
|
$exp= Array(-4, 2, 64, 1, 32, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
|
|
// here are the tests in english
|
|
public function testSweep6() {
|
|
$ar= Array('each','teacher','must', 'have', 'one','or','many','student','.');
|
|
$exp= Array(-4, 2, 64, 1, 8, 16, 32, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep7() {
|
|
$ar= Array('teacher', 'have', 'one','student','.');
|
|
$exp= Array(2, 1, 8, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep8() {
|
|
$ar= Array('teacher', 'may', 'have', 'one','student','.');
|
|
$exp= Array(2, Token::MT_QMAY, 1, 8, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep9() {
|
|
$ar= Array('teacher', 'must', 'have', 'one','student','.');
|
|
$exp= Array(2, Token::MT_QMUST, 1, 8, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
public function testSweep10() {
|
|
$ar= Array('each','teacher','may', 'have', 'one','or','many','student','.');
|
|
$exp= Array(-4, 2, Token::MT_QMAY, 1, 8, 16, 32, 2, -2);
|
|
$this->assertEquals($this->object->sweep($ar), $exp);
|
|
}
|
|
} |