nur-sery/nur_tests/b/text/WordTest.php

141 lines
5.9 KiB
PHP
Raw Normal View History

2023-12-03 22:11:29 +04:00
<?php
namespace nur\b\text;
use nur\t\TestCase;
class WordTest extends TestCase {
function testName() {
$o = new Word("l'objet#s|masculin"); # on doit spécifier le genre
$e = new Word("l'école#s|feminin"); # on doit spécifier le genre
$s = new Word("le service#s"); # le genre est implicite
$d = new Word("la direction#s"); # le genre est implicite
$l = new Word("le lieu#x");
self::assertSame("objet", $o->w());
self::assertSame("objets", $o->w(true));
self::assertSame("Objet", $o->u());
self::assertSame("Objets", $o->u(true));
self::assertSame("1 objet", $o->q());
self::assertSame("l'objet", $o->le());
self::assertSame("un objet", $o->un());
self::assertSame("de l'objet", $o->du());
self::assertSame("à l'objet", $o->au());
self::assertSame("0 objet", $o->q(0));
self::assertSame("aucun objet", $o->un(0));
self::assertSame("le 0 objet", $o->le(0));
self::assertSame("du 0 objet", $o->du(0));
self::assertSame("au 0 objet", $o->au(0));
self::assertSame("1 objet", $o->q(1));
self::assertSame("un objet", $o->un(1));
self::assertSame("l'objet", $o->le(1));
self::assertSame("de l'objet", $o->du(1));
self::assertSame("à l'objet", $o->au(1));
self::assertSame("5 objets", $o->q(5));
self::assertSame("les 5 objets", $o->un(5));
self::assertSame("les 5 objets", $o->le(5));
self::assertSame("des 5 objets", $o->du(5));
self::assertSame("aux 5 objets", $o->au(5));
self::assertSame("école", $e->w());
self::assertSame("écoles", $e->w(true));
self::assertSame("École", $e->u());
self::assertSame("Écoles", $e->u(true));
self::assertSame("0 école", $e->q(0));
self::assertSame("aucune école", $e->un(0));
self::assertSame("la 0 école", $e->le(0));
self::assertSame("de la 0 école", $e->du(0));
self::assertSame("à la 0 école", $e->au(0));
self::assertSame("1 école", $e->q(1));
self::assertSame("une école", $e->un(1));
self::assertSame("l'école", $e->le(1));
self::assertSame("de l'école", $e->du(1));
self::assertSame("à l'école", $e->au(1));
self::assertSame("5 écoles", $e->q(5));
self::assertSame("les 5 écoles", $e->un(5));
self::assertSame("les 5 écoles", $e->le(5));
self::assertSame("des 5 écoles", $e->du(5));
self::assertSame("aux 5 écoles", $e->au(5));
self::assertSame("service", $s->w());
self::assertSame("services", $s->w(true));
self::assertSame("Service", $s->u());
self::assertSame("Services", $s->u(true));
self::assertSame("0 service", $s->q(0));
self::assertSame("aucun service", $s->un(0));
self::assertSame("le 0 service", $s->le(0));
self::assertSame("du 0 service", $s->du(0));
self::assertSame("au 0 service", $s->au(0));
self::assertSame("1 service", $s->q(1));
self::assertSame("un service", $s->un(1));
self::assertSame("le service", $s->le(1));
self::assertSame("du service", $s->du(1));
self::assertSame("au service", $s->au(1));
self::assertSame("5 services", $s->q(5));
self::assertSame("les 5 services", $s->un(5));
self::assertSame("les 5 services", $s->le(5));
self::assertSame("des 5 services", $s->du(5));
self::assertSame("aux 5 services", $s->au(5));
self::assertSame("direction", $d->w());
self::assertSame("directions", $d->w(true));
self::assertSame("Direction", $d->u());
self::assertSame("Directions", $d->u(true));
self::assertSame("0 direction", $d->q(0));
self::assertSame("aucune direction", $d->un(0));
self::assertSame("la 0 direction", $d->le(0));
self::assertSame("de la 0 direction", $d->du(0));
self::assertSame("à la 0 direction", $d->au(0));
self::assertSame("1 direction", $d->q(1));
self::assertSame("une direction", $d->un(1));
self::assertSame("la direction", $d->le(1));
self::assertSame("de la direction", $d->du(1));
self::assertSame("à la direction", $d->au(1));
self::assertSame("5 directions", $d->q(5));
self::assertSame("les 5 directions", $d->un(5));
self::assertSame("les 5 directions", $d->le(5));
self::assertSame("des 5 directions", $d->du(5));
self::assertSame("aux 5 directions", $d->au(5));
self::assertSame("lieu", $l->w());
self::assertSame("lieux", $l->w(true));
self::assertSame("Lieu", $l->u());
self::assertSame("Lieux", $l->u(true));
self::assertSame("5 lieux", $l->q(5));
self::assertSame("les 5 lieux", $l->un(5));
self::assertSame("les 5 lieux", $l->le(5));
self::assertSame("des 5 lieux", $l->du(5));
self::assertSame("aux 5 lieux", $l->au(5));
$l = new Word("le lieu#x enchanteur#s");
self::assertSame("lieu enchanteur", $l->w());
self::assertSame("lieux enchanteurs", $l->w(true));
self::assertSame("Lieu enchanteur", $l->w(false, true));
self::assertSame("Lieux enchanteurs", $l->w(true, true));
self::assertSame("Lieu enchanteur", $l->u());
self::assertSame("Lieux enchanteurs", $l->u(true));
$l = new Word("le ^lieu#x ^enchanteur#s");
self::assertSame("Lieu Enchanteur", $l->w(false, true));
self::assertSame("Lieux Enchanteurs", $l->w(true, true));
self::assertSame("Lieu Enchanteur", $l->u());
self::assertSame("Lieux Enchanteurs", $l->u(true));
$l = new Word("la ^démo#s ^évidente#s");
self::assertSame("Démo Évidente", $l->w(false, true));
self::assertSame("Démos Évidentes", $l->w(true, true));
self::assertSame("Démo Évidente", $l->u());
self::assertSame("Démos Évidentes", $l->u(true));
}
function testAdjective() {
$adj = new Word("né#e#s", true);
self::assertSame("", $adj->a());
self::assertSame("", $adj->a(false));
self::assertSame("", $adj->a(false, false));
self::assertSame("née", $adj->a(true));
self::assertSame("née", $adj->a(true, false));
self::assertSame("nés", $adj->a(false, true));
self::assertSame("nées", $adj->a(true, true));
}
}