-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for determining whether a set is infinite
- Loading branch information
Showing
24 changed files
with
770 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[versions] | ||
eclipse-jdt = "2.2.600" | ||
hamcrest = "2.2" | ||
jems2 = "2.22.0" | ||
junit = "5.8.2" | ||
junit-testkit = "1.9.2" | ||
srcless = "0.3.0" | ||
confidence = "0.42.0" | ||
|
||
[libraries] | ||
srcless-annotations = { module = "org.dmfs:srcless-annotations", version.ref = "srcless" } | ||
srcless-processors = { module = "org.dmfs:srcless-processors", version.ref = "srcless" } | ||
eclipse-jdt-anntation = { module = 'org.eclipse.jdt:org.eclipse.jdt.annotation', version.ref = "eclipse-jdt" } | ||
nullless-processors = { module = "org.dmfs:nullless-processors", version.ref = "srcless" } | ||
|
||
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } | ||
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } | ||
|
||
jems2 = { module = "org.dmfs:jems2", version.ref = "jems2" } | ||
jems2-testing = { module = "org.dmfs:jems2-testing", version.ref = "jems2" } | ||
jems2-confidence = { module = "org.dmfs:jems2-confidence", version.ref = "jems2" } | ||
|
||
confidence-core = { module = "org.saynotobugs:confidence-core", version.ref = "confidence" } | ||
confidence-test = { module = "org.saynotobugs:confidence-test", version.ref = "confidence" } | ||
|
||
[bundles] | ||
srcless-processors = ["srcless-processors", "nullless-processors"] | ||
|
||
[plugins] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
dependencies { | ||
compileOnly libs.eclipse.jdt.anntation | ||
compileOnly libs.srcless.annotations | ||
annotationProcessor libs.bundles.srcless.processors | ||
api libs.confidence.core | ||
implementation libs.jems2 | ||
implementation libs.jems2.confidence | ||
api rootProject | ||
|
||
testImplementation libs.confidence.test | ||
testImplementation libs.jems2.testing | ||
testImplementation libs.junit.jupiter.api | ||
testRuntimeOnly libs.junit.jupiter.engine | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
41 changes: 41 additions & 0 deletions
41
...ecur-confidence/src/main/java/org/dmfs/rfc5545/confidence/quality/EmptyRecurrenceSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2024 Marten Gajda <marten@dmfs.org> | ||
* | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.dmfs.rfc5545.confidence.quality; | ||
|
||
import org.dmfs.jems2.confidence.optional.Absent; | ||
import org.dmfs.rfc5545.RecurrenceSet; | ||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.AllOf; | ||
import org.saynotobugs.confidence.quality.composite.Has; | ||
import org.saynotobugs.confidence.quality.composite.Not; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.iterable.EmptyIterable; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
@StaticFactories(value = "Recur", packageName = "org.dmfs.rfc5545.confidence") | ||
public final class EmptyRecurrenceSet extends QualityComposition<RecurrenceSet> | ||
{ | ||
public EmptyRecurrenceSet() | ||
{ | ||
super(new AllOf<>( | ||
new EmptyIterable(), | ||
new Not<>(new Satisfies<>(RecurrenceSet::isInfinite, new Text("is infinite"))) | ||
)); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
lib-recur-confidence/src/main/java/org/dmfs/rfc5545/confidence/quality/Finite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 Marten Gajda <marten@dmfs.org> | ||
* | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.dmfs.rfc5545.confidence.quality; | ||
|
||
import org.dmfs.jems2.predicate.Not; | ||
import org.dmfs.rfc5545.RecurrenceSet; | ||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
@StaticFactories(value = "Recur", packageName = "org.dmfs.rfc5545.confidence") | ||
public final class Finite extends QualityComposition<RecurrenceSet> | ||
{ | ||
public Finite() | ||
{ | ||
super(new Satisfies<>(new Not<>(RecurrenceSet::isInfinite), new Text("finite"))); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
lib-recur-confidence/src/main/java/org/dmfs/rfc5545/confidence/quality/Infinite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 Marten Gajda <marten@dmfs.org> | ||
* | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.dmfs.rfc5545.confidence.quality; | ||
|
||
import org.dmfs.rfc5545.RecurrenceSet; | ||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
@StaticFactories(value = "Recur", packageName = "org.dmfs.rfc5545.confidence") | ||
public final class Infinite extends QualityComposition<RecurrenceSet> | ||
{ | ||
public Infinite() | ||
{ | ||
super(new Satisfies<>(RecurrenceSet::isInfinite, new Text("infinite"))); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
lib-recur-confidence/src/main/java/org/dmfs/rfc5545/confidence/quality/StartsWith.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2024 Marten Gajda <marten@dmfs.org> | ||
* | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.dmfs.rfc5545.confidence.quality; | ||
|
||
import org.dmfs.jems2.iterable.First; | ||
import org.dmfs.rfc5545.DateTime; | ||
import org.dmfs.rfc5545.RecurrenceSet; | ||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.quality.composite.Has; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.iterable.Iterates; | ||
|
||
@StaticFactories(value = "Recur", packageName = "org.dmfs.rfc5545.confidence") | ||
public final class StartsWith extends QualityComposition<RecurrenceSet> | ||
{ | ||
public StartsWith(DateTime... instances) | ||
{ | ||
super(new Has<>("first " + instances.length + " instances", | ||
candidate -> new First<>(instances.length, candidate), new Iterates<>(instances))); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...-confidence/src/test/java/org/dmfs/rfc5545/confidence/quality/EmptyRecurrenceSetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 Marten Gajda <marten@dmfs.org> | ||
* | ||
* | ||
* 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. | ||
*/ | ||
|
||
package org.dmfs.rfc5545.confidence.quality; | ||
|
||
import org.dmfs.rfc5545.RecurrenceSet; | ||
import org.dmfs.rfc5545.instanceiterator.EmptyIterator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.dmfs.jems2.mockito.Mock.*; | ||
import static org.saynotobugs.confidence.Assertion.assertThat; | ||
import static org.saynotobugs.confidence.quality.Core.allOf; | ||
|
||
class EmptyRecurrenceSetTest | ||
{ | ||
@Test | ||
void test() | ||
{ | ||
assertThat(new EmptyRecurrenceSet(), | ||
allOf( | ||
org.saynotobugs.confidence.test.quality.Test.<RecurrenceSet>passes(mock(RecurrenceSet.class, | ||
with(RecurrenceSet::isInfinite, returning(false)), | ||
with(RecurrenceSet::iterator, returning(new EmptyIterator())))), | ||
org.saynotobugs.confidence.test.quality.Test.<RecurrenceSet>fails(mock(RecurrenceSet.class, | ||
with(RecurrenceSet::isInfinite, returning(true)), | ||
with(RecurrenceSet::iterator, returning(new EmptyIterator())))))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
rootProject.name = 'lib-recur' | ||
include 'lib-recur-confidence' | ||
include 'lib-recur-hamcrest' | ||
include 'benchmark' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.