Skip to content

Instantly share code, notes, and snippets.

@szeiger
szeiger / NegativeCompilationTests.scala
Created March 25, 2013 17:41
Compile-time unit tests that check for type-checking failures
package scala.slick.test.lifted
import com.typesafe.slick.testkit.util.ShouldNotTypecheck
class NegativeCompilationTests {
def noColumnBaseToOptionConversion = ShouldNotTypecheck("""
class FooBarBlub extends String
""", "illegal inheritance from final class String")
}
#!/bin/bash
function isIdeaProject() {
dirn=`dirname "$1"`
if [ "$dirn" = "/" ]; then
false
elif [ -d "$dirn/.idea" ]; then
true
else
isIdeaProject "$dirn"
package foo.bar.baz
class DivergenceTest {
trait ColumnBase[T]
trait ShapeLevel
trait Flat extends ShapeLevel
class Shape2[Level <: ShapeLevel, -M, U]
def testIssue146 {
case class Record(id: Int, text: String, categoryId: Int)
case class Category(id: Int, name: String, toolId: Int)
case class Tool(id: Int, name: String)
class RecordTable(tag: Tag) extends Table[Record](tag, "RECORDS") {
def id = column[Int]("id", O.PrimaryKey)
def text = column[String]("text")
def categoryId = column[Int]("category_id")
trait Foo[X]
object Foo extends EImplicits
trait Bar[X]
object Bar extends EImplicits
trait E[X]
trait EImplicits extends EImplicitsLowPrio {
implicit final def fooEvidence[T : E]: E[Foo[T]] = null
def testSimpleActionAsAction = {
class T(tag: Tag) extends Table[Int](tag, u"t") {
def a = column[Int]("a")
def * = a
}
val ts = TableQuery[T]
for {
_ <- ts.schema.create
_ <- ts ++= Seq(2, 3, 1, 5, 4)
for {
_ <- actions(
(suppliersStd.schema ++ coffeesStd.schema).create,
suppliersStd += (101, "Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199"),
suppliersStd += ( 49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"),
suppliersStd += (150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"),
coffeesStd ++= Seq(
("Colombian", 101, 799, 1, 0),
("French_Roast", 49, 799, 2, 0),
("Espresso", 150, 999, 3, 0),
val setup = seq(
(suppliersStd.schema ++ coffeesStd.schema).create,
suppliersStd += (101, "Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199"),
suppliersStd += ( 49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"),
suppliersStd += (150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"),
coffeesStd ++= Seq(
("Colombian", 101, 799, 1, 0),
("French_Roast", 49, 799, 2, 0),
("Espresso", 150, 999, 3, 0),
("Colombian_Decaf", 101, 849, 4, 0),
package scala.slick.benchmark
import java.util.concurrent.atomic.AtomicLong
object MemBarrierBench extends App {
trait Subscr[T] {
def onNext(v: T): Unit
}
buildCapabilitiesTable := {
val logger = ConsoleLogger()
Run.executeTrapExit({
System.err.println("1")
Run.run( "com.typesafe.slick.testkit.util.BuildCapabilitiesTable",
(fullClasspath in Compile).value.map(_.data),
Seq("src/sphinx/capabilities.csv"),
logger)(runner.value)
System.err.println("2")
}, logger)