aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/derived/function_arguments_with_expressions/test.sd
blob: 14aeebca6410401df0e463e5dda4f7ed442cf15a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
schema test {

    document test {
        field i1 type int {
            indexing: attribute | summary
        }
        field t1 type tensor<float>(x{}) {
            indexing: attribute | summary
        }
        field t2 type tensor<float>(x{}) {
            indexing: attribute | summary
        }
    }

    rank-profile test {

        function my_square(x) {
            expression: x * x
        }

        function test_constant() {
            expression: my_square(2) + my_square(-3.14)
        }

        function test_arithmetic() {
            expression: my_square(attribute(i1) * 2) + my_square(attribute(i1) < 1)
        }

        function test_not_neg() {
            expression: my_square( ! attribute(i1) ) + my_square( -attribute(i1) )
        }

        function test_if_in() {
            expression: my_square( if(attribute(i1) in [0,1,2], 0, 1) ) + my_square( attribute(i1) in [0,1,2] )
        }

        function test_function() {
            expression: my_square( cos(attribute(i1)) )
        }

        function test_embraced() {
            expression: my_square( ( attribute(i1) * 2 ) )
        }

        function my_func(t) {
            expression: sum(t, x) + 1
        }

        function test_func() {
            expression: my_func( attribute(t1) )
        }

        function test_tensor_func_with_expr() {
            expression: my_func( attribute(t1) * attribute(t2) )
        }

        function test_func_with_tensor_func() {
            expression: my_func( map(attribute(t1), f(x)(x * x)) )
        }

        function test_func_with_slice() {
            expression: my_square( attribute(t1){x:0} )
        }

        function test_func_via_func_with_expr() {
            expression: call_func_with_expr( attribute(t1), attribute(t2) )
        }

        function call_func_with_expr(a, b) {
            expression: my_func( a * b )
        }

    }

}