Skip to content

Commit

Permalink
add datatype identity test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbey committed Nov 12, 2024
1 parent 1daa9de commit 0bbfb7e
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::boolean::identityTrue<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(true, $f->eval(|true));
}

function <<PCT.test>> meta::pure::functions::boolean::identityFalse<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(false, $f->eval(|false));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::date::identityYear<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(%2020, $f->eval(|%2020));
}

function <<PCT.test>> meta::pure::functions::date::identityYearMonth<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(%2020-01, $f->eval(|%2020-01));
}

function <<PCT.test>> meta::pure::functions::date::identityStrictDate<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(%2020-01-01, $f->eval(|%2020-01-01));
}

function <<PCT.test>> meta::pure::functions::date::identityDateTimeWithoutMillis<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(%2020-01-01T00:00:00, $f->eval(|%2020-01-01T00:00:00));
}

function <<PCT.test>> meta::pure::functions::date::identityDateTimeWithMillis<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(%2020-01-01T00:00:00.999, $f->eval(|%2020-01-01T00:00:00.999));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::decimal::identityPositiveDecimal<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(1.1d, $f->eval(|1.1d));
}

function <<PCT.test>> meta::pure::functions::decimal::identityNegativeDecimal<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(-1.1d, $f->eval(|-1.1d));
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::float::identityPositiveFloat<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(1.1, $f->eval(|1.1));
}

function <<PCT.test>> meta::pure::functions::float::identityNegativeFloat<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(-1.1, $f->eval(|-1.1));
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::integer::identityPositiveInteger<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(1, $f->eval(|1));
}

function <<PCT.test>> meta::pure::functions::integer::identityNegativeInteger<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(-1, $f->eval(|-1));
}

function <<PCT.test>> meta::pure::functions::integer::identityMaxInteger<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(9223372036854775807, $f->eval(|9223372036854775807));
}

function <<PCT.test>> meta::pure::functions::integer::identityMinInteger<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals(-9223372036854775808, $f->eval(|-9223372036854775808));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.

import meta::pure::test::pct::*;

function <<PCT.test>> meta::pure::functions::string::identityLowercase<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals('abcde', $f->eval(|'abcde'));
}

function <<PCT.test>> meta::pure::functions::string::identityUppercase<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals('ABCDE', $f->eval(|'ABCDE'));
}

function <<PCT.test>> meta::pure::functions::string::identityEmpty<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals('', $f->eval(|''));
}

function <<PCT.test>> meta::pure::functions::string::identityUnicode<Z|y>(f:Function<{Function<{->Z[y]}>[1]->Z[y]}>[1]):Boolean[1]
{
assertEquals('\u03B2', $f->eval(|'\u03B2'));
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testGetUserFiles()
Verify.assertSetsEqual(
Sets.mutable.with("/test/codestorage/fake.pure", "/test/org/finos/legend/pure/m3/serialization/filesystem/test/level1/level1.pure", "/test/org/finos/legend/pure/m3/serialization/filesystem/test/level1/level2/level2.pure"),
this.testCodeStorage.getUserFiles().toSet());
Verify.assertEquals(231, this.combinedCodeStorage.getUserFiles().toSet().size());
Verify.assertEquals(237, this.combinedCodeStorage.getUserFiles().toSet().size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testNavigateForFilter() throws Exception
);
this.runtime.compile();

CoreInstance found = source.navigate(18, 33, this.processorSupport);
CoreInstance found = source.navigate(19, 17, this.processorSupport);
Assert.assertTrue(found instanceof Filter);
Assert.assertEquals("GoldmanSachsFilter", ((FilterInstance)found)._name());
Assert.assertEquals("filterMappingSample.pure", found.getSourceInformation().getSourceId());
Expand Down

0 comments on commit 0bbfb7e

Please sign in to comment.