@Test
    public void testTensorMerge() {
        assertTensorMerge(
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:2}:3}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2,{x:0,y:2}:3}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:1}:3}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:3}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:1}:3,{x:0,y:2}:4}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:3,{x:0,y:2}:4}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y{})", "{}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:5}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:5}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y{})", "{}"),
                Tensor.from("tensor(x{},y{})", "{{x:0,y:0}:1,{x:0,y:1}:2}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:2}:3}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:0,{x:0,y:1}:0,{x:0,y:2}:3}"));  // notice difference with sparse case - y is dense dimension here with default value 0.0
        assertTensorMerge(
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:1}:3}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:0,{x:0,y:1}:3,{x:0,y:2}:0}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:1}:3,{x:0,y:2}:4}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:0,{x:0,y:1}:3,{x:0,y:2}:4}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y[3])", "{}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:5}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:5}"));
        assertTensorMerge(
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:1,{x:0,y:1}:2}"),
                Tensor.from("tensor(x{},y[3])", "{}"),
                Tensor.from("tensor(x{},y[3])", "{{x:0,y:0}:1,{x:0,y:1}:2}"));
        assertTensorMerge(
                Tensor.from("tensor(x[4]):[5,6,7,8]"),
                Tensor.from("tensor(x[4]):[1,2,3,4]"),
                Tensor.from("tensor(x[4]):[1,2,3,4]"));
        assertTensorMerge(
                Tensor.from("tensor(x[]):{{x:0}:1,{x:1}:2,{x:2}:3,{x:3}:4}"),
                Tensor.from("tensor(x[]):{{x:0}:5,{x:1}:6}"),
                Tensor.from("tensor(x[4]):[5,6,3,4]"));
        assertTensorMerge(
                Tensor.from("tensor(x{}):{a:1,b:2}"),
                Tensor.from("tensor(x{}):{b:3,c:4}"),
                Tensor.from("tensor(x{}):{a:1,b:3,c:4}"));
        assertTensorMerge(
                Tensor.from("tensor(key{},x[4]):{a:[1,2,3,4],c:[5,6,7,8]}"),
                Tensor.from("tensor(key{},x[4]):{a:[9,10,11,12],b:[13,14,15,16]}"),
                Tensor.from("tensor(key{},x[4]):{a:[9,10,11,12],b:[13,14,15,16],c:[5,6,7,8]}"));
    }
Test the same computation made in various ways which are implemented with special-case optimizations
vespajlib/src/test/java/com/yahoo/tensor/TensorTestCase.java