diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-17 12:28:45 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-17 12:28:45 -0800 |
commit | 631b23fe2abcb3e46db1bddb67354a286720fe22 (patch) | |
tree | ff5f44264807142e6782d98630e47c168fe76c6c /cpp | |
parent | 4a753480074e3a3dda4d4414fe9a60e9704b799d (diff) | |
download | mu-631b23fe2abcb3e46db1bddb67354a286720fe22.tar.gz |
770
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/002main.cc | 1 | ||||
-rw-r--r-- | cpp/002main.test.cc | 27 |
2 files changed, 27 insertions, 1 deletions
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<instruction>::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" |