diff options
-rw-r--r-- | gruel/src/lib/pmt/pmt_io.cc | 30 | ||||
-rw-r--r-- | gruel/src/lib/pmt/qa_pmt_prims.cc | 13 |
2 files changed, 31 insertions, 12 deletions
diff --git a/gruel/src/lib/pmt/pmt_io.cc b/gruel/src/lib/pmt/pmt_io.cc index fbc556ab0..179e6b72c 100644 --- a/gruel/src/lib/pmt/pmt_io.cc +++ b/gruel/src/lib/pmt/pmt_io.cc @@ -80,20 +80,30 @@ pmt_write(pmt_t obj, std::ostream &port) port << "("; pmt_write_list_tail(obj, port); } - else if (pmt_is_dict(obj)){ - // FIXME - // port << "#<dict " << obj << ">"; - port << "#<dict>"; + else if (pmt_is_tuple(obj)){ + port << "{"; + size_t len = pmt_length(obj); + if (len > 0){ + port << pmt_tuple_ref(obj, 0); + for (size_t i = 1; i < len; i++) + port << " " << pmt_tuple_ref(obj, i); + } + port << "}"; } else if (pmt_is_vector(obj)){ - // FIXME - // port << "#<vector " << obj << ">"; - port << "#<vector>"; + port << "#("; + size_t len = pmt_length(obj); + if (len > 0){ + port << pmt_vector_ref(obj, 0); + for (size_t i = 1; i < len; i++) + port << " " << pmt_vector_ref(obj, i); + } + port << ")"; } - else if (pmt_is_tuple(obj)){ + else if (pmt_is_dict(obj)){ // FIXME - // port << "#<tuple " << obj << ">"; - port << "#<tuple>"; + // port << "#<dict " << obj << ">"; + port << "#<dict>"; } else if (pmt_is_uniform_vector(obj)){ // FIXME diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc index cf1ee0142..899674bbb 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.cc +++ b/gruel/src/lib/pmt/qa_pmt_prims.cc @@ -216,6 +216,7 @@ qa_pmt_prims::test_tuples() pmt_vector_set(v, i, s[i]); } + pmt_t t; t = pmt_make_tuple(); @@ -224,6 +225,11 @@ qa_pmt_prims::test_tuples() t = pmt_make_tuple(s[0]); check_tuple(1, s, t); + CPPUNIT_ASSERT(pmt_is_vector(v)); + CPPUNIT_ASSERT(!pmt_is_tuple(v)); + CPPUNIT_ASSERT(pmt_is_tuple(t)); + CPPUNIT_ASSERT(!pmt_is_vector(t)); + t = pmt_make_tuple(s[0], s[1]); check_tuple(2, s, t); @@ -253,13 +259,16 @@ qa_pmt_prims::test_tuples() t = pmt_make_tuple(s[0], s[1], s[2]); CPPUNIT_ASSERT_THROW(pmt_tuple_ref(t, 3), pmt_out_of_range); + CPPUNIT_ASSERT_THROW(pmt_vector_ref(t, 0), pmt_wrong_type); + CPPUNIT_ASSERT_THROW(pmt_tuple_ref(v, 0), pmt_wrong_type); t = pmt_make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9]); - check_tuple(10, s, t); - pmt_t t2 = pmt_to_tuple(v); CPPUNIT_ASSERT_EQUAL(size_t(10), pmt_length(v)); CPPUNIT_ASSERT(pmt_equal(t, t2)); + //std::cout << v << std::endl; + //std::cout << t2 << std::endl; + t = pmt_make_tuple(s[0], s[1], s[2]); pmt_t list0 = pmt_list3(s[0], s[1], s[2]); |