From 0f0fab513ab74e2d9add65e758ebf0cbf3c5cbff Mon Sep 17 00:00:00 2001 From: Don Cross Date: Fri, 18 Mar 2022 20:10:51 -0400 Subject: [PATCH] Kotlin: implemented Body enum with code docs. Implemented the Body enum, with documentation strings in comments. Reworked the Gradle build to generate GitHub Flavored Markdown (gfm) instead of html. --- generate/unit_test_kotlin | 2 +- .../io/github/cosinekitty/astronomy/Main.kt | 111 ++++++++++++++++-- .../io/github/cosinekitty/astronomy/Tests.kt | 4 + 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/generate/unit_test_kotlin b/generate/unit_test_kotlin index 64a1f22d..80458ed5 100755 --- a/generate/unit_test_kotlin +++ b/generate/unit_test_kotlin @@ -8,7 +8,7 @@ Fail() [[ "$1" == "" || "$1" == "-v" ]] || Fail "Invalid command line options." cd ../source/kotlin || Fail "Cannot change dir to ../source/kotlin" -./gradlew assemble build test dokkaHtml || Fail "Error building/testing Kotlin code." +./gradlew assemble build test dokkaGfm || Fail "Error building/testing Kotlin code." #for file in temp/kotlin_longitude_*.txt; do # ./generate $1 check ${file} || Fail "Failed verification of file ${file}" diff --git a/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/Main.kt b/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/Main.kt index fccff2ce..16818ebb 100644 --- a/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/Main.kt +++ b/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/Main.kt @@ -1,12 +1,107 @@ package io.github.cosinekitty.astronomy -fun add(a: Int, b: Int): Int = a + b +/* + Astronomy Engine for Kotlin / JVM. + https://github.com/cosinekitty/astronomy -class Accumulator { - var state = 0 - private set + MIT License - fun accumulate(x: Int) { - state += x - } -} + Copyright (c) 2019-2022 Don Cross + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +/** + * The enumeration of celestial bodies supported by Astronomy Engine. + */ +enum class Body +{ + /** + * A placeholder value representing an invalid or unknown celestial body. + */ + Invalid, + + /** + * The planet Mercury. + */ + Mercury, + + /** + * The planet Venus. + */ + Venus, + + /** + * The planet Earth. + * Some functions that accept a `Body` parameter will fail if passed this value + * because they assume that an observation is being made from the Earth, + * and therefore the Earth is not a target of observation. + */ + Earth, + + /** + * The planet Mars. + */ + Mars, + + /** + * The planet Jupiter. + */ + Jupiter, + + /** + * The planet Saturn. + */ + Saturn, + + /** + * The planet Uranus. + */ + Uranus, + + /** + * The planet Neptune. + */ + Neptune, + + /** + * The planet Pluto. + */ + Pluto, + + /** + * The Sun. + */ + Sun, + + /** + * The Earth's natural satellite, the Moon. + */ + Moon, + + /** + * The Earth/Moon Barycenter. + */ + EMB, + + /** + * The Solar System Barycenter. + */ + SSB, +}; diff --git a/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt b/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt index 672bc8a2..ac6631e1 100644 --- a/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt +++ b/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt @@ -6,6 +6,9 @@ import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.CsvSource class Tests { + + + /* @Test fun `tests accumulator`() { val accumulator = Accumulator() @@ -24,5 +27,6 @@ class Tests { fun `tests addition`(a: Int, b: Int, result: Int) { assertEquals(result, add(a, b)) } + */ }