diff --git a/spec/files/success_simple_eq_expr_boolexpr.txt b/spec/files/success_simple_eq_expr_boolexpr.txt index 78cef52..b2e3a9b 100644 --- a/spec/files/success_simple_eq_expr_boolexpr.txt +++ b/spec/files/success_simple_eq_expr_boolexpr.txt @@ -1 +1 @@ -truc_bidule = true +character = true diff --git a/spec/files/success_simple_eq_expr_number.txt b/spec/files/success_simple_eq_expr_number.txt index fa02120..365bfae 100644 --- a/spec/files/success_simple_eq_expr_number.txt +++ b/spec/files/success_simple_eq_expr_number.txt @@ -1 +1 @@ -truc_bidule = 10 +nombre = 10 diff --git a/spec/files/success_simple_eq_expr_string.txt b/spec/files/success_simple_eq_expr_string.txt index 9822ccf..f25b5b5 100644 --- a/spec/files/success_simple_eq_expr_string.txt +++ b/spec/files/success_simple_eq_expr_string.txt @@ -1 +1 @@ -truc_bidule = "test" +a_girl_has_no_name = "Arya Stark" diff --git a/spec/files/success_simple_expr_and_expr.txt b/spec/files/success_simple_expr_and_expr.txt index bda6f86..be0d13b 100644 --- a/spec/files/success_simple_expr_and_expr.txt +++ b/spec/files/success_simple_expr_and_expr.txt @@ -1 +1 @@ -truc_bidule AND machin +a_girl_has_no_name AND character diff --git a/spec/files/success_simple_expr_or_expr.txt b/spec/files/success_simple_expr_or_expr.txt index ae670ef..2135c90 100644 --- a/spec/files/success_simple_expr_or_expr.txt +++ b/spec/files/success_simple_expr_or_expr.txt @@ -1 +1 @@ -truc_bidule OR machin +a_girl_has_no_name OR character diff --git a/spec/mm2ep_depend/parser_spec.rb b/spec/mm2ep_depend/parser_spec.rb index 457c704..c942cf0 100644 --- a/spec/mm2ep_depend/parser_spec.rb +++ b/spec/mm2ep_depend/parser_spec.rb @@ -13,21 +13,19 @@ describe Mm2ep::Depend::Parser do .read(testfile('success_simple_eq_expr_boolexpr.txt')).delete("\n") parser.names = {} token = parser.parse(line.chomp) - token.errors - .select do |elem| - elem.is_a? Mm2ep::Depend::VarNotDefined - end.size.must_equal 1 + errors = token.errors.select { |el| el.is_a? Mm2ep::Depend::VarNotDefined } + errors.size.must_equal 1 + errors[0].var.must_equal 'character' end it 'has to report vars which are not defined' do - line = File - .read(testfile('success_simple_expr_or_expr.txt')).delete("\n") + line = File.read(testfile('success_simple_expr_or_expr.txt')).delete("\n") parser.names = {} token = parser.parse(line.chomp) - token.errors - .select do |elem| - elem.is_a? Mm2ep::Depend::VarNotDefined - end.size.must_equal 2 + errors = token.errors.select { |el| el.is_a? Mm2ep::Depend::VarNotDefined } + errors.size.must_equal 2 + errors[0].var.must_equal 'a_girl_has_no_name' + errors[1].var.must_equal 'character' end it 'has to report invalid_grammar' do diff --git a/spec/mm2ep_depend/simple_expr_parser_spec.rb b/spec/mm2ep_depend/simple_expr_parser_spec.rb index 6dfa7d7..a695e5f 100644 --- a/spec/mm2ep_depend/simple_expr_parser_spec.rb +++ b/spec/mm2ep_depend/simple_expr_parser_spec.rb @@ -18,7 +18,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with bool expr and return true' do line = File .read(testfile('success_simple_eq_expr_boolexpr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'true' } + parser.names = { 'character' => 'true' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -26,7 +26,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with bool expr and return false' do line = File .read(testfile('success_simple_eq_expr_boolexpr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'false' } + parser.names = { 'character' => 'false' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -34,7 +34,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with number and return true' do line = File .read(testfile('success_simple_eq_expr_number.txt')).delete("\n") - parser.names = { 'truc_bidule' => '10' } + parser.names = { 'nombre' => '10' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -42,7 +42,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with number and return false' do line = File .read(testfile('success_simple_eq_expr_number.txt')).delete("\n") - parser.names = { 'truc_bidule' => '11' } + parser.names = { 'nombre' => '11' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -50,7 +50,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with string and return true' do line = File .read(testfile('success_simple_eq_expr_string.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'test' } + parser.names = { 'a_girl_has_no_name' => 'Arya Stark' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -58,7 +58,7 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate eq with string and return false' do line = File .read(testfile('success_simple_eq_expr_string.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'tes' } + parser.names = { 'a_girl_has_no_name' => 'Sansa Stark' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -66,8 +66,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate true OR true and return true' do line = File .read(testfile('success_simple_expr_or_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'true', - 'machin' => 'true' } + parser.names = { 'a_girl_has_no_name' => 'true', + 'character' => 'true' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -75,8 +75,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate true OR false and return true' do line = File .read(testfile('success_simple_expr_or_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'true', - 'machin' => 'false' } + parser.names = { 'a_girl_has_no_name' => 'true', + 'character' => 'false' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -84,8 +84,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate false OR true and return true' do line = File .read(testfile('success_simple_expr_or_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'false', - 'machin' => 'true' } + parser.names = { 'a_girl_has_no_name' => 'false', + 'character' => 'true' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -93,8 +93,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate false OR false and return false' do line = File .read(testfile('success_simple_expr_or_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'false', - 'machin' => 'false' } + parser.names = { 'a_girl_has_no_name' => 'false', + 'character' => 'false' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -102,8 +102,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate true AND true and return true' do line = File .read(testfile('success_simple_expr_and_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'true', - 'machin' => 'true' } + parser.names = { 'a_girl_has_no_name' => 'true', + 'character' => 'true' } token = parser.parse(line.chomp) assert_equal(true, token.compute) end @@ -111,8 +111,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate true AND false and return false' do line = File .read(testfile('success_simple_expr_and_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'true', - 'machin' => 'false' } + parser.names = { 'a_girl_has_no_name' => 'true', + 'character' => 'false' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -120,8 +120,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate false AND true and return false' do line = File .read(testfile('success_simple_expr_and_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'false', - 'machin' => 'true' } + parser.names = { 'a_girl_has_no_name' => 'false', + 'character' => 'true' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end @@ -129,8 +129,8 @@ describe Mm2ep::Depend::Parser do it 'has to evaluate false AND false and return false' do line = File .read(testfile('success_simple_expr_and_expr.txt')).delete("\n") - parser.names = { 'truc_bidule' => 'false', - 'machin' => 'false' } + parser.names = { 'a_girl_has_no_name' => 'false', + 'character' => 'false' } token = parser.parse(line.chomp) assert_equal(false, token.compute) end