diff options
Diffstat (limited to 'test/junit/scala/tools/nsc')
-rw-r--r-- | test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala index e252942f89..21e338eac0 100644 --- a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala +++ b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala @@ -7,6 +7,7 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 case class Tabby(width: Int = 80, isAcross: Boolean = false, marginSize: Int = 3) extends Tabulator +case class VTabby(width: Int = 80, isAcross: Boolean = false, marginSize: Int = 3) extends VariColumnTabulator @RunWith(classOf[JUnit4]) class TabulatorTest { @@ -38,4 +39,47 @@ class TabulatorTest { assert(res(1).size == 1) // no trailing empty strings assert(res(1)(0) startsWith "c") } + // before, two 9-width cols don't fit in 20 + // but now, 5-col and 9-col do fit. + @Test def twolinerVariable() = { + val sut = VTabby(width = 20) + val items = (1 to 9) map (i => i.toString * i) + val rows = sut tabulate items + assert(rows.size == 5) + assert(rows(0).size == 2) + assert(rows(0)(0).size == 8) // width is 55555 plus margin of 3 + } + @Test def sys() = { + val sut = VTabby(width = 40) + val items = List("BooleanProp", "PropImpl", "addShutdownHook", "error", + "process", "CreatorImpl", "ShutdownHookThread", "allThreads", + "exit", "props", "Prop", "SystemProperties", + "env", "package", "runtime") + val rows = sut tabulate items + assert(rows.size == 8) + assert(rows(0).size == 2) + assert(rows(0)(0).size == "ShutdownHookThread".length + sut.marginSize) // 21 + } + @Test def syswide() = { + val sut = VTabby(width = 120) + val items = List("BooleanProp", "PropImpl", "addShutdownHook", "error", + "process", "CreatorImpl", "ShutdownHookThread", "allThreads", + "exit", "props", "Prop", "SystemProperties", + "env", "package", "runtime") + val rows = sut tabulate items + assert(rows.size == 2) + assert(rows(0).size == 8) + assert(rows(0)(0).size == "BooleanProp".length + sut.marginSize) // 14 + } + @Test def resultFits() = { + val sut = VTabby(width = 10) + // each of two lines would fit, but layout is two cols of width six > 10 + // therefore, should choose ncols = 1 + val items = List("a", "bcd", + "efg", "h") + val rows = sut tabulate items + assert(rows.size == 4) + assert(rows(0).size == 1) + assert(rows(0)(0).size == "efg".length + sut.marginSize) // 6 + } } |