Scalatest

main
Araozu 2023-10-31 06:08:04 -05:00
commit 8bda4fa726
7 changed files with 95 additions and 0 deletions

32
.gitignore vendored Normal file
View File

@ -0,0 +1,32 @@
# macOS
.DS_Store
# sbt specific
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
project/local-plugins.sbt
.history
.ensime
.ensime_cache/
.sbt-scripted/
local.sbt
# Bloop
.bsp
# VS Code
.vscode/
# Metals
.bloop/
.metals/
metals.sbt
# IDEA
.idea
.idea_modules
/.worksheet/

4
.scalafmt.conf Normal file
View File

@ -0,0 +1,4 @@
version = "3.7.14"
runner.dialect = "scala3"
preset = default
indent.main = 4

8
README.md Normal file
View File

@ -0,0 +1,8 @@
## sbt project compiled with Scala 3
### Usage
This is a normal sbt project. You can compile code with `sbt compile`, run it with `sbt run`, and `sbt console` will start a Scala 3 REPL.
For more information on the sbt-dotty plugin, see the
[scala3-example-project](https://github.com/scala/scala3-example-project/blob/main/README.md).

12
build.sbt Normal file
View File

@ -0,0 +1,12 @@
val scala3Version = "3.3.1"
lazy val root = project
.in(file("."))
.settings(
name := "advent22",
version := "0.1.0-SNAPSHOT",
scalaVersion := scala3Version,
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test
)

1
project/build.properties Normal file
View File

@ -0,0 +1 @@
sbt.version=1.9.7

29
src/main/scala/Main.scala Normal file
View File

@ -0,0 +1,29 @@
import scala.io.StdIn.readLine
import scala.util.Random
// Number guessing game
@main def hello: Unit =
val right_answer = Random().nextInt(101)
var attempts = 0
println(s"Hello, you have <unlimited> attempts")
while true do
attempts += 1
print("Enter a number: ")
readLine().toIntOption match
case Some(n) if n == right_answer =>
println(s"yeh, the number was $n. you win. you took $attempts attempts")
return
case Some(n) if n > right_answer =>
println("you too high mah man")
case Some(n) if n < right_answer =>
println("a litte too low mate")
case Some(_) =>
println("??? why are you even seeing this message???")
case None =>
println("that ain't a numbah. you wasted an attempt!")
println(s"you outta attemps. you lost. the numbah was $right_answer btw")
println("kthxbye")

View File

@ -0,0 +1,9 @@
// For more information on writing tests, see
// https://scalameta.org/munit/docs/getting-started.html
class MySuite extends munit.FunSuite {
test("example test that succeeds") {
val obtained = 42
val expected = 42
assertEquals(obtained, expected)
}
}