From 631b23fe2abcb3e46db1bddb67354a286720fe22 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 17 Feb 2015 12:28:45 -0800 Subject: 770 --- cpp/002main.cc | 1 + cpp/002main.test.cc | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'cpp') diff --git a/cpp/002main.cc b/cpp/002main.cc index a2bc0729..5f057946 100644 --- a/cpp/002main.cc +++ b/cpp/002main.cc @@ -210,6 +210,7 @@ bool next_instruction(istream& in, instruction* curr) { if (find(words.begin(), words.end(), "<-") != words.end()) { //? cout << "instruction yields products\n"; //? 1 for (; *p != "<-"; ++p) { + if (*p == ",") continue; //? cout << "product: " << *p << '\n'; //? 1 //? products.push_back(*p); //? 1 curr->products.push_back(reagent(*p)); diff --git a/cpp/002main.test.cc b/cpp/002main.test.cc index 77d0ee38..36e6a669 100644 --- a/cpp/002main.test.cc +++ b/cpp/002main.test.cc @@ -1,7 +1,6 @@ void test_parse() { compile("recipe main [\n" " 1:integer <- copy 23:literal\n" -//? " 1:integer, 2:integer <- copy 23:literal\n" "]\n"); CHECK(Recipe_number.find("main") != Recipe_number.end()); recipe r = Recipe[Recipe_number["main"]]; @@ -21,6 +20,32 @@ void test_parse() { CHECK_EQ(i->products[0].properties.size(), 0); } +void test_parse2() { + compile("recipe main [\n" + " 1:integer, 2:integer <- copy 23:literal\n" + "]\n"); + CHECK(Recipe_number.find("main") != Recipe_number.end()); + recipe r = Recipe[Recipe_number["main"]]; + vector::iterator i = r.step.begin(); + CHECK_EQ(i->is_label, false); + CHECK_EQ(i->label, ""); + CHECK_EQ(i->operation, Recipe_number["copy"]); + CHECK_EQ(i->ingredients.size(), 1); + CHECK_EQ(i->ingredients[0].name, string("23")); + CHECK_EQ(i->ingredients[0].types.size(), 1); + CHECK_EQ(i->ingredients[0].types[0], Type_number["literal"]); + CHECK_EQ(i->ingredients[0].properties.size(), 0); + CHECK_EQ(i->products.size(), 2); + CHECK_EQ(i->products[0].name, string("1")); + CHECK_EQ(i->products[0].types.size(), 1); + CHECK_EQ(i->products[0].types[0], Type_number["integer"]); + CHECK_EQ(i->products[0].properties.size(), 0); + CHECK_EQ(i->products[1].name, string("2")); + CHECK_EQ(i->products[1].types.size(), 1); + CHECK_EQ(i->products[1].types[0], Type_number["integer"]); + CHECK_EQ(i->products[1].properties.size(), 0); +} + void test_literal() { compile("recipe main [\n" " 1:integer <- copy 23:literal\n" -- cgit 1.4.1-2-gfad0