add a test for coercing a nested array (#6326)
* add a test for coercing a nested array Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix test Signed-off-by: Jess Frazelle <github@jessfraz.com> * add console log Signed-off-by: Jess Frazelle <github@jessfraz.com> * add console log Signed-off-by: Jess Frazelle <github@jessfraz.com> * add test for what we get back on no_outputs error Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my log Signed-off-by: Jess Frazelle <github@jessfraz.com> * move test Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Paul Tagliamonte <paul@zoo.dev>
This commit is contained in:
		@ -2119,4 +2119,73 @@ d = cos(30)
 | 
			
		||||
        assert_value_and_type("c", &result, 1.0, NumericType::count());
 | 
			
		||||
        assert_value_and_type("d", &result, 0.0, NumericType::count());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[tokio::test(flavor = "multi_thread")]
 | 
			
		||||
    async fn coerce_nested_array() {
 | 
			
		||||
        let mut exec_state = ExecState::new(&crate::ExecutorContext::new_mock().await);
 | 
			
		||||
 | 
			
		||||
        let mixed1 = KclValue::MixedArray {
 | 
			
		||||
            value: vec![
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 0.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 1.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
                KclValue::HomArray {
 | 
			
		||||
                    value: vec![
 | 
			
		||||
                        KclValue::Number {
 | 
			
		||||
                            value: 2.0,
 | 
			
		||||
                            ty: NumericType::count(),
 | 
			
		||||
                            meta: Vec::new(),
 | 
			
		||||
                        },
 | 
			
		||||
                        KclValue::Number {
 | 
			
		||||
                            value: 3.0,
 | 
			
		||||
                            ty: NumericType::count(),
 | 
			
		||||
                            meta: Vec::new(),
 | 
			
		||||
                        },
 | 
			
		||||
                    ],
 | 
			
		||||
                    ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
 | 
			
		||||
                },
 | 
			
		||||
            ],
 | 
			
		||||
            meta: Vec::new(),
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        // Principal types
 | 
			
		||||
        let tym1 = RuntimeType::Array(
 | 
			
		||||
            Box::new(RuntimeType::Primitive(PrimitiveType::Number(NumericType::count()))),
 | 
			
		||||
            ArrayLen::NonEmpty,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        let result = KclValue::HomArray {
 | 
			
		||||
            value: vec![
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 0.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 1.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 2.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
                KclValue::Number {
 | 
			
		||||
                    value: 3.0,
 | 
			
		||||
                    ty: NumericType::count(),
 | 
			
		||||
                    meta: Vec::new(),
 | 
			
		||||
                },
 | 
			
		||||
            ],
 | 
			
		||||
            ty: RuntimeType::Primitive(PrimitiveType::Number(NumericType::count())),
 | 
			
		||||
        };
 | 
			
		||||
        assert_coerce_results(&mixed1, &tym1, &result, &mut exec_state);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user