more tests

This commit is contained in:
WanderingPenwing 2024-12-12 13:56:12 +01:00
parent 1a0701f0b9
commit 4edede94cb
5 changed files with 80 additions and 10 deletions

View file

@ -1 +1 @@
{"categories":[{"name":"todo","content":[{"name":"display element","description":"// Hello there","id":6},{"name":"if","description":"implémente if avec des guillemets de délimitation","id":1},{"name":"scope variable","description":"// Hello there","id":6},{"name":"while","description":"implémente un while","id":2},{"name":"else","description":"// Hello there","id":7},{"name":"break","description":"// Hello there","id":8},{"name":"continue","description":"// Hello there","id":9},{"name":"compilation","description":"// Hello there","id":3},{"name":"puis à la ligne, alinéa","description":"// Hello there","id":1}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"comparaison","description":"// Hello there","id":2},{"name":"booleen type","description":"// Hello there","id":4},{"name":"soixante-dix","description":"// Hello there","id":1},{"name":"parenthese comparaison","description":"// Hello there","id":1},{"name":"test comparaison","description":"// Hello there","id":4},{"name":"error ligne compilation","description":"// Hello there","id":2},{"name":"commentaires","description":"// Hello there","id":3},{"name":"compile time verification","description":"odre des termes rpn","id":1}]},{"name":"bug","content":[]},{"name":"to test","content":[{"name":"test correct error","description":"manque point\nmauvaise expression mathematique","id":3},{"name":"test commentaire","description":"// Hello there","id":3},{"name":"test puis in texte","description":"// Hello there","id":2},{"name":"test multiple space in texte","description":"// Hello there","id":3},{"name":"guillemet mal ferme","description":"// Hello there","id":4},{"name":"enchainement puis","description":"// Hello there","id":5}]},{"name":"bonus","content":[{"name":"stop cheating with \"-\"","description":"// Hello there","id":5},{"name":"affiche ligne et position erreur","description":"// Hello there","id":1}]},{"name":"+","content":[]}]}
{"categories":[{"name":"todo","content":[{"name":"erreur calcul bool/nombre","description":"affiche element precedent lorsque mauvais enchainement","id":1},{"name":"display element","description":"for better print","id":6},{"name":"if","description":"implémente if avec des guillemets de délimitation","id":1},{"name":"scope variable","description":"// Hello there","id":6},{"name":"while","description":"implémente un while","id":2},{"name":"else","description":"// Hello there","id":7},{"name":"break","description":"// Hello there","id":8},{"name":"continue","description":"// Hello there","id":9},{"name":"compilation","description":"// Hello there","id":3},{"name":"puis à la ligne, alinéa","description":"// Hello there","id":1}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"comparaison","description":"// Hello there","id":2},{"name":"booleen type","description":"// Hello there","id":4},{"name":"soixante-dix","description":"// Hello there","id":1},{"name":"parenthese comparaison","description":"// Hello there","id":1},{"name":"test comparaison","description":"// Hello there","id":4},{"name":"error ligne compilation","description":"// Hello there","id":2},{"name":"commentaires","description":"// Hello there","id":3},{"name":"compile time verification","description":"odre des termes rpn","id":1},{"name":"test multiple space in texte","description":"// Hello there","id":3},{"name":"test puis in texte","description":"// Hello there","id":2},{"name":"enchainement puis","description":"// Hello there","id":5},{"name":"guillemet mal ferme","description":"// Hello there","id":4}]},{"name":"bug","content":[]},{"name":"to test","content":[{"name":"tests mod","description":"// Hello there","id":3}]},{"name":"bonus","content":[{"name":"stop cheating with \"-\"","description":"// Hello there","id":5},{"name":"affiche ligne et position erreur","description":"// Hello there","id":1}]},{"name":"+","content":[]}]}

View file

@ -302,7 +302,7 @@ mod test {
use super::*;
#[test]
fn teste_conversion_booleen_texte() {
fn conversion_booleen_texte() {
for b in [true, false].iter() {
let texte = booleen_comme_texte(*b); // Convert number to text
match texte_comme_booleen(&texte) { // Convert text back to number
@ -317,7 +317,7 @@ mod test {
}
#[test]
fn teste_calcul_booleen() {
fn calcul_booleen() {
let pendragon = Pendragon::nouveau();
let mut configurations = Vec::new();
for b1 in [true, false] {
@ -358,7 +358,7 @@ mod test {
}
#[test]
fn teste_comparaison() {
fn comparaison_booleen() {
let pendragon = Pendragon::nouveau();
for (a, b) in [(1, 4), (2, 2), (3, 1), (0, 3)] {
let possible_expressions = vec![
@ -399,7 +399,7 @@ mod test {
}
#[test]
fn teste_combinaison() {
fn combinaison_booleen() {
let pendragon = Pendragon::nouveau();
for a in 0..5 {
for b in 0..5 {
@ -438,7 +438,7 @@ mod test {
}
#[test]
fn teste_erreur_calcul_booleen() {
fn erreur_calcul_booleen() {
let pendragon = Pendragon::nouveau();
let textes_invalide = vec![
"vrai et et faux",

View file

@ -123,3 +123,39 @@ pub fn format_de_variable(nom: &str) -> bool {
}
true
}
#[cfg(test)]
mod test {
use std::collections::HashMap;
use super::*;
#[test]
fn commentaire_valide() {
panic!("todo");
}
#[test]
fn commentaire_invalide() {
panic!("todo");
}
#[test]
fn ponctuation_valide() {
panic!("todo");
}
#[test]
fn ponctuation_invalide() {
panic!("todo");
}
#[test]
fn commande_valide() {
panic!("todo");
}
#[test]
fn commande_invalide() {
panic!("todo");
}
}

View file

@ -369,7 +369,7 @@ mod test {
use std::collections::HashMap;
use super::*;
#[test]
fn teste_conversion_nombres_texte() {
fn conversion_nombres_texte() {
for i in [0, 1, 42, 70, 123, 999, 1031, 1_001_091, 72_036_854_775_807usize].iter() {
let texte = nombre_comme_texte(*i); // Convert number to text
match texte_comme_nombre(&texte) { // Convert text back to number
@ -384,7 +384,7 @@ mod test {
}
#[test]
fn teste_calcul_nombre() {
fn calcul_nombre() {
let pendragon = Pendragon::nouveau();
let a = 2345678;
let b = 987654;
@ -415,7 +415,7 @@ mod test {
}
#[test]
fn teste_erreur_calcul_nombre() {
fn erreur_calcul_nombre() {
let pendragon = Pendragon::nouveau();
let textes_invalide = vec![
"un un fois un",

View file

@ -129,7 +129,7 @@ mod test {
use super::*;
#[test]
fn teste_calcul_texte() {
fn calcul_texte() {
let pendragon = Pendragon::nouveau();
let a = 2345678;
let b = 987654;
@ -154,4 +154,38 @@ mod test {
}
}
}
#[test]
fn conversion_texte() {
let pendragon = Pendragon::nouveau();
let texte = "\"hello aaaa puis AERTY et ou fois six\"";
match pendragon.elements_texte(texte) {
Ok(expression) => {
if expression.len() != 2 {
panic!("L'expression (texte) devrait contenir deux éléments (texte et puis), contient : {:?}", expression);
}
assert_eq!(expression[0], Element::Texte(texte[1..texte.len()-1].into()), "Calcul d'expression (texte) donne un mauvais résultat : {}", texte);
}
Err(raison) => {
panic!("Conversion échouée (texte) : {}", raison);
}
}
}
#[test]
fn erreur_conversion_texte() {
let pendragon = Pendragon::nouveau();
let textes = vec![
"trois puis puis un",
"\" test",
];
for texte in textes {
let Err(raison) = pendragon.elements_texte(texte) else {
panic!("Ne devrait pas réussir à convertir le texte '{}'", texte);
};
let ErreurPendragon::TexteInvalide(_) = raison else {
panic!("Erreur imprévue pour convertir le texte '{}' : {}", texte, raison);
};
}
}
}