diff --git a/pendragon.project b/pendragon.project index 0ba7531..6b33ca9 100644 --- a/pendragon.project +++ b/pendragon.project @@ -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":[]}]} \ No newline at end of file +{"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":[]}]} \ No newline at end of file diff --git a/src/pendragon/booleen.rs b/src/pendragon/booleen.rs index cd9c3f9..d0e9192 100644 --- a/src/pendragon/booleen.rs +++ b/src/pendragon/booleen.rs @@ -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", diff --git a/src/pendragon/mod.rs b/src/pendragon/mod.rs index 5c92835..5ad3750 100644 --- a/src/pendragon/mod.rs +++ b/src/pendragon/mod.rs @@ -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"); + } +} \ No newline at end of file diff --git a/src/pendragon/nombre.rs b/src/pendragon/nombre.rs index d7b1b79..e1f33fc 100644 --- a/src/pendragon/nombre.rs +++ b/src/pendragon/nombre.rs @@ -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", diff --git a/src/pendragon/texte.rs b/src/pendragon/texte.rs index db8225a..9ed4dc4 100644 --- a/src/pendragon/texte.rs +++ b/src/pendragon/texte.rs @@ -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); + }; + } + } } \ No newline at end of file