aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/derived/function_arguments/test.sd
blob: 0e9998d8bdfb136e7dd97af54a5251579692b230 (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
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
schema args {

    document args {
        field f1 type float {
            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 sin(x) {  # shadows internal function "sin"
            expression: sqrt(x)
        }

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

        function test_numeric_constants() {
            expression: my_func(10) + my_func(10.1) + my_func(-10) + my_func(-10.1)
        }

        function test_string_constants() {
            expression: my_func("string")  # + my_func(-"string") -> -"string" parses but not a valid Value
        }

        function test_features() {
            expression: my_func(attribute(f1)) + my_func(term(0).significance) + my_func(cos(-1.1)) + my_func(cos(attribute(f1)))
        }

        function test_feature_shadowing() {
            expression: my_func(sin(3.14)) + my_func(cos(3.14))
        }

        function test_identifiers() {
            expression: my_func(if) + my_func(unknown) + my_func(cos)
        }

        function test_parses_but_invalid() {
            expression: my_func(attribute(query(q1)))
        }

    }

}