diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-12 18:13:12 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-12 18:13:12 +0000 |
commit | ee4cc17eb7f75361c2395e8f38716de14e223b87 (patch) | |
tree | 9842ea8854fa46113e3798ea2869bd3f5a536790 /test/files/run/sysprops.scala | |
parent | e86934018bf3078a1a9751c16b95621a04575707 (diff) | |
download | scala-ee4cc17eb7f75361c2395e8f38716de14e223b87.tar.gz scala-ee4cc17eb7f75361c2395e8f38716de14e223b87.tar.bz2 scala-ee4cc17eb7f75361c2395e8f38716de14e223b87.zip |
A small addition to the library to address some...
A small addition to the library to address something bugging me forever.
It's a light interface to system properties. It's not intended to solve
all property issues for all time, only to greatly improve on the overly
ad-hoc ways things are presently done. Feedback welcome. Sorry it's
coming in this late but it arises from writing the tools to fix the bugs
to allow that release to happen. That's nature's circle of bugs. Review
by community.
Diffstat (limited to 'test/files/run/sysprops.scala')
-rw-r--r-- | test/files/run/sysprops.scala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/files/run/sysprops.scala b/test/files/run/sysprops.scala new file mode 100644 index 0000000000..d3df22d634 --- /dev/null +++ b/test/files/run/sysprops.scala @@ -0,0 +1,50 @@ +import sys._ + +/** Basic sys.Prop test. */ +object Test { + val key = "ding.dong.doobie" + + def bool() = { + val prop = Prop.bool(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() + } +} |