All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core_functions_unclassified.meta.compileValueSpecification.pure Maven / Gradle / Ivy

There is a newer version: 4.67.9
Show newest version
// Copyright 2022 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

Class meta::pure::functions::meta::CompilationResult
{
    result:ValueSpecification[0..1];
    failure:CompilationFailure[0..1];

    succeeded()
    {
        $this.failure->isEmpty()
    }:Boolean[1];

    failed()
    {
        !$this.succeeded();
    }:Boolean[1];
}

Class meta::pure::functions::meta::CompilationFailure
{
    message:String[1];
    sourceInformation:SourceInformation[0..1];
}

native function meta::pure::functions::meta::compileValueSpecification<|m>(value:String[m]):CompilationResult[m];

function <> meta::pure::functions::meta::tests::compileValueSpecification::testCompileValueSpecification():Boolean[1]
{
    let res = compileValueSpecification('meta::pure::functions::meta::tests::model::CC_Person.all()->filter(t | $t.lastName == 3)');
    let expr = $res.result;
    assertEquals('filter', $expr->cast(@SimpleFunctionExpression).func.functionName);
    assertSize($expr->cast(@SimpleFunctionExpression).parametersValues, 2);
}

function <> meta::pure::functions::meta::tests::reactivate::testPredicateReactivate():Boolean[1]
{
    let res = compileValueSpecification('[1,2,3]->exists(x|$x>1)');
    let expr = $res.result;

    assertEquals(true, $expr->toOne()->reactivate());
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy