From 3f34ac9369978b396d00a4fd02c9fb06b8eea621 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 9 Jun 2018 08:59:33 -0700 Subject: 4256 - get rid of container metadata entirely We have some ugly duplication in computing size_of on containers between layers 30/33 and 55. --- 032array.cc | 80 ------------------------------------------------------------- 1 file changed, 80 deletions(-) (limited to '032array.cc') diff --git a/032array.cc b/032array.cc index a696b450..3bde42fb 100644 --- a/032array.cc +++ b/032array.cc @@ -200,86 +200,6 @@ def foo [ ] # shouldn't die -//:: containers inside arrays -//: make sure we compute container sizes inside arrays - -:(before "End compute_container_sizes Non-atom Special-cases") -else if (type->left->name == "array") - compute_container_sizes(array_element(type), pending_metadata, location_for_error_messages); - -:(before "End Unit Tests") -void test_container_sizes_from_array() { - // a container we don't have the size for - reagent container("x:point"); - CHECK(!contains_key(Container_metadata, container.type)); - // scanning an array of the container precomputes the size of the container - reagent r("x:array:point"); - compute_container_sizes(r, ""); - CHECK(contains_key(Container_metadata, container.type)); - CHECK_EQ(get(Container_metadata, container.type).size, 2); -} - -void test_container_sizes_from_address_to_array() { - // a container we don't have the size for - reagent container("x:point"); - CHECK(!contains_key(Container_metadata, container.type)); - // scanning an address to an array of the container precomputes the size of the container - reagent r("x:address:array:point"); - compute_container_sizes(r, ""); - CHECK(contains_key(Container_metadata, container.type)); - CHECK_EQ(get(Container_metadata, container.type).size, 2); -} - -void test_container_sizes_from_static_array() { - // a container we don't have the size for - reagent container("x:point"); - int old_size = SIZE(Container_metadata); - // scanning an address to an array of the container precomputes the size of the container - reagent r("x:array:point:10"); - compute_container_sizes(r, ""); - CHECK(contains_key(Container_metadata, container.type)); - CHECK_EQ(get(Container_metadata, container.type).size, 2); - // no non-container types precomputed - CHECK_EQ(SIZE(Container_metadata)-old_size, 1); -} - -void test_container_sizes_from_address_to_static_array() { - // a container we don't have the size for - reagent container("x:point"); - int old_size = SIZE(Container_metadata); - // scanning an address to an array of the container precomputes the size of the container - reagent r("x:address:array:point:10"); - compute_container_sizes(r, ""); - CHECK(contains_key(Container_metadata, container.type)); - CHECK_EQ(get(Container_metadata, container.type).size, 2); - // no non-container types precomputed - CHECK_EQ(SIZE(Container_metadata)-old_size, 1); -} - -void test_container_sizes_from_repeated_address_and_array_types() { - // a container we don't have the size for - reagent container("x:point"); - int old_size = SIZE(Container_metadata); - // scanning repeated address and array types modifying the container precomputes the size of the container - reagent r("x:address:array:address:array:point:10"); - compute_container_sizes(r, ""); - CHECK(contains_key(Container_metadata, container.type)); - CHECK_EQ(get(Container_metadata, container.type).size, 2); - // no non-container types precomputed - CHECK_EQ(SIZE(Container_metadata)-old_size, 1); -} - -void test_container_sizes_on_unknown_type() { - // a container we don't have the size for - reagent container("x:point"); - int old_size = SIZE(Container_metadata); - // scanning address to array with a typo - reagent r("x:address:array:adress:number"); - compute_container_sizes(r, ""); // should not crash - // no non-container types precomputed - CHECK_EQ(SIZE(Container_metadata), old_size); -} - //:: To access elements of an array, use 'index' :(scenario index) -- cgit 1.4.1-2-gfad0