Exemplo n.º 1
0
  OOP Method::run(State& S, Arguments& args) {
    if(arity_ > 0 && args.count() != arity_) {
      return OOP::make_unwind(
        Exception::create(S, "ArgumentError",
                                  "Expected %d, got %d", arity_, args.count()));
    }

    if(func_) {
      HandleScope scope(S);

      return *func_(S, args.self(), args);
    } else if(code_) {
      return S.vm().run(S, this, args);
    }

    return OOP::nil();
  }
Exemplo n.º 2
0
void Console::Ecrire(QString ligne)
{
    QString reponse;
    QString nomCommande;
    BaseCommande* commande;
    QRegExp regex;
    QStringList parties;
    Arguments* arguments = new Arguments();

    nomCommande = ligne.section(' ', 0, 0);
    ligne.remove(0, nomCommande.length());

    regex = QRegExp(" -(\\S*) ?(\".*\"|\\S*\\b?)(.*)");
    do
    {
        regex.indexIn(ligne);
        parties = regex.capturedTexts();
        if (!parties.at(0).isEmpty())
        {
            arguments->Ajouter(new Argument(parties.at(1), parties.at(2)));
        }
        ligne = parties.at(3);
    }
    while (!ligne.isEmpty());

    commande = m_Commandes->value(nomCommande);
    if (commande)
    {
        if (commande->getArgsMin() <= arguments->count())
        {
            reponse = commande->Executer(arguments);
        }
        else
        {
            reponse = nomCommande + " : Pas assez d'arguments";
        }
    } else
    {
        reponse = nomCommande + " : Commande inconnue";
    }
    Imprimer(reponse);
}
TEST(CountNotEqual, ValidData)
{
	Arguments object = createObject();
	ASSERT_NE(object.count(), 3);
}
TEST(CountIsEqual, ValidData)
{
	Arguments object = initializeObject();
	ASSERT_EQ(object.count(), 2);
}