|
Scala example source code file (sysprops.scala)
The Scala sysprops.scala source code
import sys._
/** Basic sys.Prop test. */
object Test {
val key = "ding.dong.doobie"
def bool() = {
val prop = BooleanProp.valueIsTrue(key)
assert(prop.key == key)
prop.clear()
assert(!prop.value)
assert(!prop.isSet)
assert(prop.get != null)
prop set "dingus"
assert(prop.get == "dingus")
assert(!prop.value)
prop set "true"
assert(prop.value)
prop.toggle()
assert(!prop.value)
prop.enable()
assert(prop.value)
prop.disable()
assert(!prop.value)
}
def int() = {
val prop = Prop[Int](key)
prop.clear()
assert(prop.value == 0)
prop.set("523")
assert(prop.value == 523)
prop.set("DingusInt")
try { println(prop.value) ; assert(false, "should not get here") }
catch { case _: Exception => () }
}
def double() = {
val prop = Prop[Double](key)
prop.set("55.0")
assert(prop.value == 55.0)
}
def main(args: Array[String]): Unit = {
bool()
int()
double()
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala sysprops.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.