From 61c46db282f0539aba78375788e38848c3bbd8d1 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 16 Feb 2015 16:22:31 -0800 Subject: 765 - first failing C++ test --- cpp/002main.cc | 37 +++++++++++++++++++++++++++++++------ cpp/002main.test.cc | 7 +++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 cpp/002main.test.cc (limited to 'cpp') diff --git a/cpp/002main.cc b/cpp/002main.cc index 7aac3d6b..c2baea50 100644 --- a/cpp/002main.cc +++ b/cpp/002main.cc @@ -101,7 +101,10 @@ struct type_info { vector > elements; // only if is_record or is_array }; -unordered_map type; +typedef int type_number; +unordered_map Type_name; +unordered_map Type; +unordered_map Memory; struct reagent { string name; @@ -110,15 +113,35 @@ struct reagent { }; struct instruction { - recipe_number op; - vector ingredients; - vector products; + bool is_label; + string label; // only if is_label + recipe_number operation; // only if !is_label + vector ingredients; // only if !is_label + vector products; // only if !is_label +}; + +struct recipe { + vector step; }; -void load(const char* filename) { +unordered_map Recipe; + +void load(string filename) { +} + +void run(string function_name) { +} + +void setup_memory() { + Memory.clear(); +} + +void setup_types() { + Type_name["integer"] = 1; + Type[1].size = 1; } -void run(const char* function_name) { +void compile(string form) { } @@ -148,6 +171,8 @@ void verify() { } void setup() { + setup_memory(); + setup_types(); Passed = true; } diff --git a/cpp/002main.test.cc b/cpp/002main.test.cc new file mode 100644 index 00000000..b622828b --- /dev/null +++ b/cpp/002main.test.cc @@ -0,0 +1,7 @@ +void test_literal() { + compile("function main [\n" + " 1:integer <- copy 23:literal\n" + "]\n"); + run("main"); + CHECK_EQ(Memory[1], 23); +} -- cgit 1.4.1-2-gfad0