From 85cf9e1849b452da681d11ead314f46ba8be9512 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 16 Nov 2014 18:42:55 -0800 Subject: Moved some book-data stuff into the scalatex file to take advantage of the new multi-line Scala expressions --- book/src/main/scala/book/BookData.scala | 12 - .../book/indepth/SemanticDifferences.scalatex | 23 +- .../src/test/scala/scalatex/BasicTests.scala | 868 ++++++++++----------- .../src/test/scala/scalatex/ErrorTests.scala | 720 ++++++++--------- 4 files changed, 811 insertions(+), 812 deletions(-) diff --git a/book/src/main/scala/book/BookData.scala b/book/src/main/scala/book/BookData.scala index 0a47aaf..2f92c6c 100644 --- a/book/src/main/scala/book/BookData.scala +++ b/book/src/main/scala/book/BookData.scala @@ -3,18 +3,6 @@ package book import acyclic.file object BookData { - val myTable = Seq( - ("Most of java.lang.*", "j.l.Thread, j.l.Runtime, ..."), - ("Almost all of scala.*", "s.c.parallel, s.tools.nsc"), - ("Some of java.util.*", "org.omg.CORBA, sun.misc.*"), - ("Scala Macros: upickle, scala-async, scalaxy, etc", "Reflection: scala-pickling, scala-reflect"), - ("Pure-Scala ecosystem: shapeless, scalaz, scalatags, utest", "Java-dependent: Scalatest, Scalate"), - ("JS stuff: XmlHttpRequest, Websockets. Localstorage", " JVM stuff: Netty, akka, spray, file IO, JNI"), - ("HTML DOM, Canvas, WebGL", "AWT, Swing, SWT, OpenGL"), - ("JavaScript libraries: chipmunk.js, hand.js, react.js, jquery", "Java ecosystem: guice, junit, apache-commons, log4j"), - ("IntelliJ, Eclipse, SBT, Chrome console, firebug", "Scala REPL, Yourkit, VisualVM, JProfiler") - ) - lazy val javaAPIs = { import java.io.File def recursiveListFiles(f: File): Array[File] = { diff --git a/book/src/main/scalatex/book/indepth/SemanticDifferences.scalatex b/book/src/main/scalatex/book/indepth/SemanticDifferences.scalatex index 7bc1a41..4cd78bb 100644 --- a/book/src/main/scalatex/book/indepth/SemanticDifferences.scalatex +++ b/book/src/main/scalatex/book/indepth/SemanticDifferences.scalatex @@ -128,6 +128,17 @@ We believe that this covers most use cases of scala.Enumeration. Please let us know if another (generalized) rewrite would make your life easier. @sect{Library Differences} + @val myTable = Seq( + ("Most of java.lang.*", "j.l.Thread, j.l.Runtime, ..."), + ("Almost all of scala.*", "s.c.parallel, s.tools.nsc"), + ("Some of java.util.*", "org.omg.CORBA, sun.misc.*"), + ("Scala Macros: upickle, scala-async, scalaxy, etc", "Reflection: scala-pickling, scala-reflect"), + ("Pure-Scala ecosystem: shapeless, scalaz, scalatags, utest", "Java-dependent: Scalatest, Scalate"), + ("JS stuff: XmlHttpRequest, Websockets. Localstorage", " JVM stuff: Netty, akka, spray, file IO, JNI"), + ("HTML DOM, Canvas, WebGL", "AWT, Swing, SWT, OpenGL"), + ("JavaScript libraries: chipmunk.js, hand.js, react.js, jquery", "Java ecosystem: guice, junit, apache-commons, log4j"), + ("IntelliJ, Eclipse, SBT, Chrome console, firebug", "Scala REPL, Yourkit, VisualVM, JProfiler") + ) @p Scala.js differs from Scala-JVM not just in the corner-cases of the language, but also in the libraries available. Scala-JVM has access to JVM APIs and the wealth of the Java libraries, while Scala.js has access to Javascript APIs and Javascript libraries. It's also possible to write pure-Scala libraries that run on both Scala.js and Scala-JVM, as detailed @a("here"). @p @@ -136,7 +147,7 @@ @val tableHead = pureTable(th("Can Use"), th("Can't Use")) @tableHead - @for(tuple <- BookData.myTable) + @for(tuple <- myTable) @tr @td{@tuple._1}@td{@tuple._2} @@ -145,7 +156,7 @@ @sect{Standard Library} @tableHead - @for(tuple <- BookData.myTable.slice(0, 3)) + @for(tuple <- myTable.slice(0, 3)) @tr @td{@tuple._1}@td{@tuple._2} @@ -156,7 +167,7 @@ @sect{Reflection v.s. Macros} @tableHead - @for(tuple <- BookData.myTable.slice(3, 4)) + @for(tuple <- myTable.slice(3, 4)) @tr @td{@tuple._1}@td{@tuple._2} @@ -168,7 +179,7 @@ @sect{Pure-Scala v.s. Java Libraries} @tableHead - @for(tuple <- BookData.myTable.slice(4, 5)) + @for(tuple <- myTable.slice(4, 5)) @tr @td{@tuple._1}@td{@tuple._2} @p @@ -178,7 +189,7 @@ @sect{Javascript APIs v.s. JVM APIs} @tableHead - @for(tuple <- BookData.myTable.slice(5, 7)) + @for(tuple <- myTable.slice(5, 7)) @tr @td{@tuple._1}@td{@tuple._2} @@ -192,7 +203,7 @@ @sect{Java tooling v.s. Scala/Browser tooling} @tableHead - @for(tuple <- BookData.myTable.slice(7, 8)) + @for(tuple <- myTable.slice(7, 8)) @tr @td{@tuple._1}@td{@tuple._2} diff --git a/scalatexApi/src/test/scala/scalatex/BasicTests.scala b/scalatexApi/src/test/scala/scalatex/BasicTests.scala index fc4bff8..4bc362c 100644 --- a/scalatexApi/src/test/scala/scalatex/BasicTests.scala +++ b/scalatexApi/src/test/scala/scalatex/BasicTests.scala @@ -1,468 +1,468 @@ -//package scalatex -//import utest._ -//import scala.collection.mutable.ArrayBuffer -//import scalatex.stages._ -//import scalatags.Text.all._ +package scalatex +import utest._ +import scala.collection.mutable.ArrayBuffer +import scalatex.stages._ +import scalatags.Text.all._ + + +/** +* Created by haoyi on 7/14/14. +*/ +object BasicTests extends TestSuite{ + import TestUtil._ + + val tests = TestSuite{ + + 'helloWorld{ + object omg { + def wtf(s: Frag*): Frag = Seq[Frag]("|", s, "|") + } + def str = "hear me moo" + check( + tw(""" + @omg.wtf + i @b{am} cow @str + """), + "|iamcowhearmemoo|" + ) + } + 'interpolation{ + 'chained-check( + tw("omg @scala.math.pow(0.5, 3) wtf"), + "omg 0.125 wtf" + ) + 'parens-check( + tw("omg @(1 + 2 + 3 + 4) wtf"), + "omg 10 wtf" + ) + 'block-check( + tw(""" + @{"lol" * 3} + @{ + val omg = "omg" + omg * 2 + } + """), + """ + lollollol + omgomg + """ + ) + } + 'definitions{ + 'imports{ + object Whee{ + def func(x: Int) = x * 2 + } + check( + tw(""" + @import math._ + @import Whee.func + @abs(-10) + @p + @max(1, 2) + @func(2) + """), + """ + 10 +

+ 2 + 4 +

+ """ + ) + } + 'valDefVar{ + check( + tw(""" + Hello + @val x = 1 + World @x + @def y = "omg" + mooo + @y + """), + """ + Hello + World 1 + mooo + omg + """ + ) + } + 'classObjectTrait{ + check( + tw(""" + @trait Trait{ + def tt = 2 + } + Hello + @case object moo extends Trait{ + val omg = "wtf" + } + + @moo.toString + @moo.omg + @case class Foo(i: Int, s: String, b: Boolean) + TT is @moo.tt + @Foo(10, "10", true).toString + """), + """ + Hello + moo + wtf + TT is 2 + Foo(10, 10, true) + """ + ) + } + } + 'parenArgumentLists{ + 'attributes{ + check( + tw(""" + @div(id:="my-id"){ omg } + @div(id:="my-id") + omg + """), + """ + omg + omg + """ + ) + } +// 'multiline{ // -// -///** -//* Created by haoyi on 7/14/14. -//*/ -//object BasicTests extends TestSuite{ -// import TestUtil._ -// -// val tests = TestSuite{ -// -// 'helloWorld{ -// object omg { -// def wtf(s: Frag*): Frag = Seq[Frag]("|", s, "|") -// } -// def str = "hear me moo" -// check( -// tw(""" -// @omg.wtf -// i @b{am} cow @str -// """), -// "|iamcowhearmemoo|" -// ) -// } -// 'interpolation{ -// 'chained-check( -// tw("omg @scala.math.pow(0.5, 3) wtf"), -// "omg 0.125 wtf" -// ) -// 'parens-check( -// tw("omg @(1 + 2 + 3 + 4) wtf"), -// "omg 10 wtf" -// ) -// 'block-check( -// tw(""" -// @{"lol" * 3} -// @{ -// val omg = "omg" -// omg * 2 -// } -// """), -// """ -// lollollol -// omgomg -// """ -// ) -// } -// 'definitions{ -// 'imports{ -// object Whee{ -// def func(x: Int) = x * 2 -// } -// check( -// tw(""" -// @import math._ -// @import Whee.func -// @abs(-10) -// @p -// @max(1, 2) -// @func(2) -// """), -// """ -// 10 -//

-// 2 -// 4 -//

-// """ -// ) -// } -// 'valDefVar{ // check( // tw(""" -// Hello -// @val x = 1 -// World @x -// @def y = "omg" -// mooo -// @y +// @div( +// h1("Hello World"), +// p("I am a ", b{"cow"}) +// ) // """), // """ -// Hello -// World 1 -// mooo -// omg +//
+//

Hello World

+//

I am a cow

+//
// """ // ) // } -// 'classObjectTrait{ -// check( -// tw(""" -// @trait Trait{ -// def tt = 2 -// } -// Hello -// @case object moo extends Trait{ -// val omg = "wtf" -// } + } + 'grouping{ + 'negative{ + // The indentation for "normal" text is ignored; we only + // create blocks from the indentation following a scala + // @xxx expression + check( + tw(""" + I am cow hear me moo + I weigh twice as much as you + And I look good on the barbecue + Yoghurt curds cream cheese and butter + Comes from liquids from my udder + I am cow I am cow hear me moooooo + """), + """ + I am cow hear me moo + I weigh twice as much as you + And I look good on the barbecue + Yoghurt curds cream cheese and butter + Comes from liquids from my udder + I am cow I am cow hear me moooooo + """ + ) + } + 'indentation{ + 'simple{ + val world = "World2" + + check( + tw(""" + @h1 + Hello World + @h2 + hello @world + @h3 + Cow + """), + """ +

HelloWorld

+

helloWorld2

+

Cow

+ """ + ) + } + 'linearNested{ + check( + tw(""" + @h1 @span @a Hello World + @h2 @span @a hello + @b world + @h3 @i + @div Cow + """), + """ +

HelloWorld +

helloworld +

Cow + """ + ) + } + 'crasher{ + tw(""" +@html + @head + @meta + @div + @a + @span + """) + } + } + 'curlies{ + 'simple{ + val world = "World2" + + check( + tw("""@div{Hello World}"""), + """
HelloWorld
""" + ) + } + 'multiline{ + check( + tw(""" + @div{ + Hello + } + """), + """ +
Hello
+ """ + ) + } + } + 'mixed{ + check( + tw(""" + @div{ + Hello + @div + @h1 + WORLD @b{!!!} + lol + @p{ + @h2{Header 2} + } + } + """), + """ +
+ Hello +
+

WORLD!!!lol

+

Header2

+
+
+ """ + ) + } // -// @moo.toString -// @moo.omg -// @case class Foo(i: Int, s: String, b: Boolean) -// TT is @moo.tt -// @Foo(10, "10", true).toString -// """), -// """ -// Hello -// moo -// wtf -// TT is 2 -// Foo(10, 10, true) -// """ -// ) -// } -// } -// 'parenArgumentLists{ -// 'attributes{ +// 'args{ +// val things = Seq(1, 2, 3) // check( // tw(""" -// @div(id:="my-id"){ omg } -// @div(id:="my-id") -// omg -// """), -// """ -// omg -// omg -// """ -// ) -// } -//// 'multiline{ -//// -//// check( -//// tw(""" -//// @div( -//// h1("Hello World"), -//// p("I am a ", b{"cow"}) -//// ) -//// """), -//// """ -////
-////

Hello World

-////

I am a cow

-////
-//// """ -//// ) -//// } -// } -// 'grouping{ -// 'negative{ -// // The indentation for "normal" text is ignored; we only -// // create blocks from the indentation following a scala -// // @xxx expression -// check( -// tw(""" -// I am cow hear me moo -// I weigh twice as much as you -// And I look good on the barbecue -// Yoghurt curds cream cheese and butter -// Comes from liquids from my udder -// I am cow I am cow hear me moooooo +// @ul +// @things.map { x => +// @li +// @x +// } // """), -// """ -// I am cow hear me moo -// I weigh twice as much as you -// And I look good on the barbecue -// Yoghurt curds cream cheese and butter -// Comes from liquids from my udder -// I am cow I am cow hear me moooooo -// """ -// ) -// } -// 'indentation{ -// 'simple{ -// val world = "World2" -// -// check( -// tw(""" -// @h1 -// Hello World -// @h2 -// hello @world -// @h3 -// Cow -// """), -// """ -//

HelloWorld

-//

helloWorld2

-//

Cow

-// """ -// ) -// } -// 'linearNested{ -// check( -// tw(""" -// @h1 @span @a Hello World -// @h2 @span @a hello -// @b world -// @h3 @i -// @div Cow -// """), -// """ -//

HelloWorld -//

helloworld -//

Cow -// """ -// ) -// } -// 'crasher{ // tw(""" -//@html -// @head -// @meta -// @div -// @a -// @span -// """) -// } -// } -// 'curlies{ -// 'simple{ -// val world = "World2" +// @ul +// @things.map x => +// @li +// @x // -// check( -// tw("""@div{Hello World}"""), -// """
HelloWorld
""" -// ) -// } -// 'multiline{ -// check( -// tw(""" -// @div{ -// Hello -// } -// """), -// """ -//
Hello
-// """ -// ) -// } -// } -// 'mixed{ -// check( -// tw(""" -// @div{ -// Hello -// @div -// @h1 -// WORLD @b{!!!} -// lol -// @p{ -// @h2{Header 2} -// } -// } // """), // """ -//
-// Hello -//
-//

WORLD!!!lol

-//

Header2

-//
-//
+//
    +//
  • 1
  • +//
  • 2
  • +//
  • 3
  • +//
// """ // ) // } -//// -//// 'args{ -//// val things = Seq(1, 2, 3) -//// check( -//// tw(""" -//// @ul -//// @things.map { x => -//// @li -//// @x -//// } -//// """), -//// tw(""" -//// @ul -//// @things.map x => -//// @li -//// @x -//// -//// """), -//// """ -////
    -////
  • 1
  • -////
  • 2
  • -////
  • 3
  • -////
-//// """ -//// ) -//// } -// } -//// -// 'loops { -//// -// * - check( -// tw(""" -// @for(x <- 0 until 3) -// lol -// """), -// tw(""" -// @for(x <- 0 until 3){ -// lol -// } -// """), -// "lollollol" -// ) + } // + 'loops { // -// * - check( -// tw(""" -// @p -// @for(x <- 0 until 2) -// @for(y <- 0 until 2) -// lol@x@y -// """), -// tw( """ -// @p -// @for(x <- 0 until 2){ -// @for(y <- 0 until 2) -// lol@x@y -// } -// """), -// tw(""" -// @p -// @for(x <- 0 until 2) -// @for(y <- 0 until 2){ -// lol@x@y -// } -// """), -// "

lol00lol01lol10lol11

" -// ) -// check( -// tw(""" -// @p -// @for(x <- 0 until 2) -// @for(y <- 0 until 2) -// lol@x@y -// """), -// "

lol00lol01lol10lol11

" -// ) -// -// * - check( -// tw( -// """ -// @for(x <- 0 until 2; y <- 0 until 2) -// @div{@x@y} -// -// """), -// """
00
01
10
11
""" -// ) -// } -// -// 'ifElse{ -// 'basicExamples{ + * - check( + tw(""" + @for(x <- 0 until 3) + lol + """), + tw(""" + @for(x <- 0 until 3){ + lol + } + """), + "lollollol" + ) + + + * - check( + tw(""" + @p + @for(x <- 0 until 2) + @for(y <- 0 until 2) + lol@x@y + """), + tw( """ + @p + @for(x <- 0 until 2){ + @for(y <- 0 until 2) + lol@x@y + } + """), + tw(""" + @p + @for(x <- 0 until 2) + @for(y <- 0 until 2){ + lol@x@y + } + """), + "

lol00lol01lol10lol11

" + ) + check( + tw(""" + @p + @for(x <- 0 until 2) + @for(y <- 0 until 2) + lol@x@y + """), + "

lol00lol01lol10lol11

" + ) + + * - check( + tw( + """ + @for(x <- 0 until 2; y <- 0 until 2) + @div{@x@y} + + """), + """
00
01
10
11
""" + ) + } + + 'ifElse{ + 'basicExamples{ + * - check( + tw(""" + @if(false) + Hello + @else + lols + @p + """), + "lols

" + ) + + * - check( + tw(""" + @div + @if(true) + Hello + @else + lols + """), + "
Hello
" + ) + + * - check( + tw(""" + @div + @if(true) + Hello + @else + lols + """), + "
Hello
" + ) + * - check( + tw(""" + @if(false) + Hello + @else + lols + """), + "lols" + ) + * - check( + tw(""" + @if(false) + Hello + @else + lols + @img + """), + "lols" + ) + * - check( + tw(""" + @p + @if(true) + Hello + @else + lols + """), + tw(""" + @p + @if(true){ + Hello + }else{ + lols + } + """), + "

Hello

" + ) + } +// 'funkyExpressions{ // * - check( // tw(""" -// @if(false) -// Hello -// @else -// lols // @p -// """), -// "lols

" -// ) -// -// * - check( -// tw(""" -// @div -// @if(true) -// Hello +// @if(true == false == (true.==(false))) +// @if(true == false == (true.==(false))) +// Hello1 +// @else +// lols1 // @else -// lols +// @if(true == false == (true.==(false))) +// Hello2 +// @else +// lols2 // """), -// "
Hello
" -// ) -// -// * - check( -// tw(""" -// @div -// @if(true) -// Hello -// @else -// lols -// """), -// "
Hello
" -// ) -// * - check( -// tw(""" -// @if(false) -// Hello -// @else -// lols -// """), -// "lols" -// ) -// * - check( -// tw(""" -// @if(false) -// Hello -// @else -// lols -// @img -// """), -// "lols" +// "

Hello1

" // ) // * - check( // tw(""" // @p -// @if(true) -// Hello +// @if(true == false != (true.==(false))) +// @if(true == false != (true.==(false))) +// Hello1 +// @else +// lols1 // @else -// lols +// @if(true == false != (true.==(false))) +// Hello2 +// @else +// lols2 // """), -// tw(""" -// @p -// @if(true){ -// Hello -// }else{ -// lols -// } -// """), -// "

Hello

" +// "

lols2

" // ) // } -//// 'funkyExpressions{ -//// * - check( -//// tw(""" -//// @p -//// @if(true == false == (true.==(false))) -//// @if(true == false == (true.==(false))) -//// Hello1 -//// @else -//// lols1 -//// @else -//// @if(true == false == (true.==(false))) -//// Hello2 -//// @else -//// lols2 -//// """), -//// "

Hello1

" -//// ) -//// * - check( -//// tw(""" -//// @p -//// @if(true == false != (true.==(false))) -//// @if(true == false != (true.==(false))) -//// Hello1 -//// @else -//// lols1 -//// @else -//// @if(true == false != (true.==(false))) -//// Hello2 -//// @else -//// lols2 -//// """), -//// "

lols2

" -//// ) -//// } -// } -// } -// -//} + } + } + +} diff --git a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala index a7e6155..d8cd4f5 100644 --- a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala +++ b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala @@ -1,373 +1,373 @@ -//package scalatex -// -//import utest._ -//import scalatex.stages._ -//import scalatags.Text.all._ -//import scalatex.Internals.{DebugFailure, twRuntimeErrors} -// -///** -//* Created by haoyi on 7/14/14. -//*/ -//object ErrorTests extends TestSuite{ -// def check(x: => Unit, expectedMsg: String, expectedError: String) = { -// val DebugFailure(msg, pos) = intercept[DebugFailure](x) -// def format(str: String) = { -// val whitespace = " \t\n".toSet -// "\n" + str.dropWhile(_ == '\n') -// .reverse -// .dropWhile(whitespace.contains) -// .reverse -// } -// // Format these guys nicely to normalize them and make them -// // display nicely in the assert error message if it blows up -// val formattedPos = format(pos) -// val formattedExpectedPos = format(expectedError) -// -// assert(msg.contains(expectedMsg)) -// assert(formattedPos == formattedExpectedPos) -// -// } -// val tests = TestSuite{ -// -// -// 'simple - check( -// twRuntimeErrors("omg @notInScope lol"), -// """not found: value notInScope""", -// """ -// twRuntimeErrors("omg @notInScope lol"), -// ^ -// """ -// ) -// -// 'chained{ -// 'properties { +package scalatex + +import utest._ +import scalatex.stages._ +import scalatags.Text.all._ +import scalatex.Internals.{DebugFailure, twRuntimeErrors} + +/** +* Created by haoyi on 7/14/14. +*/ +object ErrorTests extends TestSuite{ + def check(x: => Unit, expectedMsg: String, expectedError: String) = { + val DebugFailure(msg, pos) = intercept[DebugFailure](x) + def format(str: String) = { + val whitespace = " \t\n".toSet + "\n" + str.dropWhile(_ == '\n') + .reverse + .dropWhile(whitespace.contains) + .reverse + } + // Format these guys nicely to normalize them and make them + // display nicely in the assert error message if it blows up + val formattedPos = format(pos) + val formattedExpectedPos = format(expectedError) + + assert(msg.contains(expectedMsg)) + assert(formattedPos == formattedExpectedPos) + + } + val tests = TestSuite{ + + + 'simple - check( + twRuntimeErrors("omg @notInScope lol"), + """not found: value notInScope""", + """ + twRuntimeErrors("omg @notInScope lol"), + ^ + """ + ) + + 'chained{ + 'properties { + * - check( + twRuntimeErrors("omg @math.lol lol"), + """object lol is not a member of package math""", + """ + twRuntimeErrors("omg @math.lol lol"), + ^ + """ + ) + + * - check( + twRuntimeErrors("omg @math.E.lol lol"), + """value lol is not a member of Double""", + """ + twRuntimeErrors("omg @math.E.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.scala.math.lol lol"), + """object lol is not a member of package math""", + """ + twRuntimeErrors("omg @_root_.scala.math.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.scala.gg.lol lol"), + """object gg is not a member of package scala""", + """ + twRuntimeErrors("omg @_root_.scala.gg.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), + """object ggnore is not a member of package """, + """ + twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), + ^ + """ + ) + } + 'calls{ + * - check( + twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), + """object QQ is not a member of package scala""", + """ + twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), + "value tdo is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), + "value z is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), + "value z is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), + "value cow is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.smath.abs.cow.sum.z"), + "object smath is not a member of package scala", + """ + twRuntimeErrors("@scala.smath.abs.cow.sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.cos('omg)"), + "type mismatch", + """ + twRuntimeErrors("@scala.math.cos('omg)"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.cos[omg]('omg)"), + "not found: type omg", + """ + twRuntimeErrors("@scala.math.cos[omg]('omg)"), + ^ + """ + ) + * - check( + twRuntimeErrors(""" + I am cow hear me moo + @scala.math.abs(-10).tdo(10).sum.z + I weigh twice as much as you + """), + "value tdo is not a member of Int", + """ + @scala.math.abs(-10).tdo(10).sum.z + ^ + """ + ) + } + 'curlies{ + * - check( + twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), + "missing arguments for method foldLeft", + """ + twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), + ^ + """ + ) + + * - check( + twRuntimeErrors("@Nil.foldLeft{XY}"), + "missing arguments for method foldLeft", + """ + twRuntimeErrors("@Nil.foldLeft{XY}"), + ^ + """ + ) + // * - check( -// twRuntimeErrors("omg @math.lol lol"), -// """object lol is not a member of package math""", -// """ -// twRuntimeErrors("omg @math.lol lol"), -// ^ -// """ -// ) -// -// * - check( -// twRuntimeErrors("omg @math.E.lol lol"), -// """value lol is not a member of Double""", -// """ -// twRuntimeErrors("omg @math.E.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.scala.math.lol lol"), -// """object lol is not a member of package math""", -// """ -// twRuntimeErrors("omg @_root_.scala.math.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.scala.gg.lol lol"), -// """object gg is not a member of package scala""", -// """ -// twRuntimeErrors("omg @_root_.scala.gg.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), -// """object ggnore is not a member of package """, -// """ -// twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), -// ^ -// """ -// ) -// } -// 'calls{ -// * - check( -// twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), -// """object QQ is not a member of package scala""", -// """ -// twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), -// "value tdo is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), -// "value z is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), -// "value z is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), -// "value cow is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.smath.abs.cow.sum.z"), -// "object smath is not a member of package scala", -// """ -// twRuntimeErrors("@scala.smath.abs.cow.sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.cos('omg)"), -// "type mismatch", -// """ -// twRuntimeErrors("@scala.math.cos('omg)"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.cos[omg]('omg)"), -// "not found: type omg", -// """ -// twRuntimeErrors("@scala.math.cos[omg]('omg)"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors(""" -// I am cow hear me moo -// @scala.math.abs(-10).tdo(10).sum.z -// I weigh twice as much as you -// """), -// "value tdo is not a member of Int", -// """ -// @scala.math.abs(-10).tdo(10).sum.z -// ^ -// """ -// ) -// } -// 'curlies{ -// * - check( -// twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), -// "missing arguments for method foldLeft", -// """ -// twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), -// ^ -// """ -// ) -// -// * - check( -// twRuntimeErrors("@Nil.foldLeft{XY}"), -// "missing arguments for method foldLeft", -// """ -// twRuntimeErrors("@Nil.foldLeft{XY}"), -// ^ -// """ -// ) -// -//// * - check( -//// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"), -//// "type mismatch", -//// """ -//// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"), -//// ^ -//// """ -//// ) -//// * - check( -//// twRuntimeErrors("@Nil.map{ omg}"), -//// "too many arguments for method map", -//// """ -//// twRuntimeErrors("@Nil.map{ omg}"), -//// ^ -//// """ -//// ) -// } -// 'callContents{ -// * - check( -// twRuntimeErrors("@scala.math.abs((1, 2).wtf)"), -// "value wtf is not a member of (Int, Int)", -// """ -// twRuntimeErrors("@scala.math.abs((1, 2).wtf)"), -// ^ +// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"), +// "type mismatch", +// """ +// twRuntimeErrors("@Seq(1).map{(y: String) => omg}"), +// ^ // """ // ) -// // * - check( -// twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"), -// "value wtf is not a member of String", -// """ -// twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"), -// ^ +// twRuntimeErrors("@Nil.map{ omg}"), +// "too many arguments for method map", // """ -// ) -// } -// } -// 'ifElse{ -// 'oneLine { -// * - check( -// twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"), -// "object > is not a member of package math", -// """ -// twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"), +// twRuntimeErrors("@Nil.map{ omg}"), // ^ // """ // ) -// * - check( -// twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"), -// "Unspecified value parameter y", -// """ -// twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"), -// "too many arguments for method sin: (x: Double)Double", -// """ -// twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"), -// ^ -// """ -// ) -// } -// 'multiLine{ -// * - check( -// twRuntimeErrors(""" -// Ho Ho Ho -// -// @if(math != 10) -// I am a cow -// @else -// You are a cow -// GG -// """), -// "object != is not a member of package math", -// """ -// @if(math != 10) -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors(""" -// Ho Ho Ho -// -// @if(4 != 10) -// I am a cow @math.lols -// @else -// You are a cow -// GG -// """), -// "object lols is not a member of package math", -// """ -// I am a cow @math.lols -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors(""" -// Ho Ho Ho -// -// @if(12 != 10) -// I am a cow -// @else -// @math.E.toString.gog(1) -// GG -// """), -// "value gog is not a member of String", -// """ -// @math.E.toString.gog(1) -// ^ -// """ -// ) -// } -// } -// 'forLoop{ -// 'oneLine{ -// 'header - check( -// twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"), -// """value omglolol is not a member of Int""", -// """ -// twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"), -// ^ -// """ -// ) -// -// 'body - check( -// twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"), -// """too many arguments for method +""", -// """ -// twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"), -// ^ -// """ -// ) -// } -// 'multiLine{ -// 'body - check( -// twRuntimeErrors(""" -// omg -// @for(x <- 0 until 10) -// I am cow hear me moo -// I weigh twice as much as @x.kkk -// """), -// """value kkk is not a member of Int""", -// """ -// I weigh twice as much as @x.kkk -// ^ -// """ -// ) -// } -// } -// 'multiLine{ -// 'missingVar - check( -// twRuntimeErrors(""" -// omg @notInScope lol -// """), -// """not found: value notInScope""", -// """ -// omg @notInScope lol -// ^ -// """ -// ) -//// 'wrongType - check( -//// twRuntimeErrors(""" -//// omg @{() => ()} lol -//// """), -//// """type mismatch""", -//// """ -//// omg @{() => ()} lol -//// ^ -//// """ -//// ) -// -// 'bigExpression - check( + } + 'callContents{ + * - check( + twRuntimeErrors("@scala.math.abs((1, 2).wtf)"), + "value wtf is not a member of (Int, Int)", + """ + twRuntimeErrors("@scala.math.abs((1, 2).wtf)"), + ^ + """ + ) + + * - check( + twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"), + "value wtf is not a member of String", + """ + twRuntimeErrors("@scala.math.abs((1, 2).swap._1.toString().map(_.toString.wtf))"), + ^ + """ + ) + } + } + 'ifElse{ + 'oneLine { + * - check( + twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"), + "object > is not a member of package math", + """ + twRuntimeErrors("@if(math > 10){ 1 }else{ 2 }"), + ^ + """ + ) + * - check( + twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"), + "Unspecified value parameter y", + """ + twRuntimeErrors("@if(true){ (@math.pow(10)) * 10 }else{ 2 }"), + ^ + """ + ) + * - check( + twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"), + "too many arguments for method sin: (x: Double)Double", + """ + twRuntimeErrors("@if(true){ * 10 }else{ @math.sin(3, 4, 5) }"), + ^ + """ + ) + } + 'multiLine{ + * - check( + twRuntimeErrors(""" + Ho Ho Ho + + @if(math != 10) + I am a cow + @else + You are a cow + GG + """), + "object != is not a member of package math", + """ + @if(math != 10) + ^ + """ + ) + * - check( + twRuntimeErrors(""" + Ho Ho Ho + + @if(4 != 10) + I am a cow @math.lols + @else + You are a cow + GG + """), + "object lols is not a member of package math", + """ + I am a cow @math.lols + ^ + """ + ) + * - check( + twRuntimeErrors(""" + Ho Ho Ho + + @if(12 != 10) + I am a cow + @else + @math.E.toString.gog(1) + GG + """), + "value gog is not a member of String", + """ + @math.E.toString.gog(1) + ^ + """ + ) + } + } + 'forLoop{ + 'oneLine{ + 'header - check( + twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"), + """value omglolol is not a member of Int""", + """ + twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"), + ^ + """ + ) + + 'body - check( + twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"), + """too many arguments for method +""", + """ + twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"), + ^ + """ + ) + } + 'multiLine{ + 'body - check( + twRuntimeErrors(""" + omg + @for(x <- 0 until 10) + I am cow hear me moo + I weigh twice as much as @x.kkk + """), + """value kkk is not a member of Int""", + """ + I weigh twice as much as @x.kkk + ^ + """ + ) + } + } + 'multiLine{ + 'missingVar - check( + twRuntimeErrors(""" + omg @notInScope lol + """), + """not found: value notInScope""", + """ + omg @notInScope lol + ^ + """ + ) +// 'wrongType - check( // twRuntimeErrors(""" -// @{ -// val x = 1 + 2 -// val y = new Object() -// val z = y * x -// x -// } +// omg @{() => ()} lol // """), -// "value * is not a member of Object", +// """type mismatch""", // """ -// val z = y * x -// ^ +// omg @{() => ()} lol +// ^ // """ // ) -// } -// } -//} + + 'bigExpression - check( + twRuntimeErrors(""" + @{ + val x = 1 + 2 + val y = new Object() + val z = y * x + x + } + """), + "value * is not a member of Object", + """ + val z = y * x + ^ + """ + ) + } + } +} -- cgit v1.2.3