diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2017-02-18 23:13:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-18 23:13:59 +0100 |
commit | f3f1c4623b3815f1385317190bf72baabd98fdff (patch) | |
tree | 526aece2cd29373a6a693e6cdd56bdc700f91d02 /tests/disabled/scalac-dependent/pos/t7591.scala | |
parent | 1946b36ca4abb7ba8264c18af95bc9c9c94f67ee (diff) | |
parent | 5aac086d63807331e380bb2d861e4e07800b1f63 (diff) | |
download | dotty-f3f1c4623b3815f1385317190bf72baabd98fdff.tar.gz dotty-f3f1c4623b3815f1385317190bf72baabd98fdff.tar.bz2 dotty-f3f1c4623b3815f1385317190bf72baabd98fdff.zip |
Merge pull request #1989 from dotty-staging/remove/scalac-tests
Disable tests that require scala-compiler
Diffstat (limited to 'tests/disabled/scalac-dependent/pos/t7591.scala')
-rw-r--r-- | tests/disabled/scalac-dependent/pos/t7591.scala | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/disabled/scalac-dependent/pos/t7591.scala b/tests/disabled/scalac-dependent/pos/t7591.scala new file mode 100644 index 000000000..dd127b881 --- /dev/null +++ b/tests/disabled/scalac-dependent/pos/t7591.scala @@ -0,0 +1,86 @@ +/* NEST (New Scala Test) + * Copyright 2007-2013 LAMP/EPFL + * @author Paul Phillips + */ + +import scala.tools.cmd._ + +/** A sample command specification for illustrative purposes. + * First take advantage of the meta-options: + * + * // this command creates an executable runner script "demo" + * % scala scala.tools.cmd.Demo --self-update demo + * + * // this one creates and sources a completion file - note backticks + * % `./demo --bash` + * + * // and now you have a runner with working completion + * % ./demo --<tab> + * --action --defint --int + * --bash --defstr --str + * --defenv --self-update --unary + * + * The normal option configuration is plausibly self-explanatory. + */ +trait DemoSpec extends Spec with Meta.StdOpts with Interpolation { + lazy val referenceSpec = DemoSpec + lazy val programInfo = Spec.Info("demo", "Usage: demo [<options>]", "scala.tools.cmd.Demo") + + help("""Usage: demo [<options>]""") + heading("Unary options:") + + val optIsUnary = "unary" / "a unary option" --? ; + ("action" / "a body which may be run") --> println("Hello, I am the --action body.") + + heading("Binary options:") + val optopt = "str" / "an optional String" --| + val optoptInt = ("int" / "an optional Int") . --^[Int] + val optEnv = "defenv" / "an optional String" defaultToEnv "PATH" + val optDefault = "defstr" / "an optional String" defaultTo "default" + val optDefaultInt = "defint" / "an optional Int" defaultTo -1 + val optExpand = "alias" / "an option which expands" expandTo ("--int", "15") +} + +object DemoSpec extends DemoSpec with Property { + lazy val propMapper = new PropertyMapper(DemoSpec) + + type ThisCommandLine = SpecCommandLine + def creator(args: List[String]) = + new SpecCommandLine(args) { + override def errorFn(msg: String) = { println("Error: " + msg) ; sys.exit(0) } + } +} + +class Demo(args: List[String]) extends DemoSpec with Instance { +// TODO NEEDS MANUAL CHANGE (early initializers) +// BEGIN copied early initializers +val parsed = DemoSpec(args: _*) +// END copied early initializers + + import java.lang.reflect._ + + def helpMsg = DemoSpec.helpMsg + def demoSpecMethods = this.getClass.getMethods.toList + private def isDemo(m: Method) = (m.getName startsWith "opt") && !(m.getName contains "$") && (m.getParameterTypes.isEmpty) + + def demoString(ms: List[Method]) = { + val longest = ms map (_.getName.length) max + val formatStr = " %-" + longest + "s: %s" + val xs = ms map (m => formatStr.format(m.getName, m.invoke(this))) + + xs mkString ("Demo(\n ", "\n ", "\n)\n") + } + + override def toString = demoString(demoSpecMethods filter isDemo) +} + +object Demo { + def main(args: Array[String]): Unit = { + val runner = new Demo(args.toList) + + if (args.isEmpty) + println(runner.helpMsg) + + println(runner) + } +} |