From ee4cc17eb7f75361c2395e8f38716de14e223b87 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 12 Mar 2011 18:13:12 +0000 Subject: 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. --- test/files/run/sysprops.scala | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/files/run/sysprops.scala (limited to 'test/files/run') 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() + } +} -- cgit v1.2.3