Author: boisvert
Date: Sun Nov 8 05:54:50 2009
New Revision: 833834
URL: http://svn.apache.org/viewvc?rev=833834&view=rev
Log:
Fix Scalatest specs (1.0 API compatibility); revert to Scalacheck
1.5 since 1.6 is incompatible with Scalatest 1.0
Modified:
buildr/trunk/lib/buildr/scala/tests.rb
buildr/trunk/spec/scala/tests_spec.rb
Modified: buildr/trunk/lib/buildr/scala/tests.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/tests.rb?rev=833834&r1=833833&r2=833834&view=diff
===
===
===
=====================================================================
--- buildr/trunk/lib/buildr/scala/tests.rb (original)
+++ buildr/trunk/lib/buildr/scala/tests.rb Sun Nov 8 05:54:50 2009
@@ -23,7 +23,7 @@
module Buildr::Scala
# Scala::Check is available when using Scala::Test or Scala::Specs
module Check
- VERSION = '1.6'
+ VERSION = '1.5'
class << self
def version
@@ -112,7 +112,7 @@
# TODO: This should be name=>value pairs!
#ant.includes group_includes.join(" ") if group_includes
#ant.excludes group_excludes.join(" ") if group_excludes
- (options[:properties] || []).each { |name, value|
ant.property :name=>name, :value=>value }
+ (options[:properties] || []).each { |name, value|
ant.config :name=>name, :value=>value }
end
end
@@ -127,7 +127,7 @@
File.open(reportFile, "r") do |input|
while (line = input.gets) do
failed = (line =~ /(TESTS? FAILED -)|(RUN STOPPED)|
(RUN ABORTED)/) unless failed
- completed |= (line =~ /Run completed\./)
+ completed |= (line =~ /Run completed/)
break if (failed)
end
end
Modified: buildr/trunk/spec/scala/tests_spec.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/spec/scala/tests_spec.rb?rev=833834&r1=833833&r2=833834&view=diff
===
===
===
=====================================================================
--- buildr/trunk/spec/scala/tests_spec.rb (original)
+++ buildr/trunk/spec/scala/tests_spec.rb Sun Nov 8 05:54:50 2009
@@ -113,7 +113,7 @@
val sum = 1 + 1
assert(sum === 2)
}
-
+
class InnerSuite extends FunSuite {
test("addition") {
val sum = 1 + 1
@@ -180,15 +180,16 @@
write 'src/test/scala/PropertyTestSuite.scala', <<-SCALA
import org.scalatest._
class PropertyTestSuite extends FunSuite {
- var properties = Map[String, Any]()
+ var configMap = Map[String, Any]()
test("testProperty") {
- assert(properties("name") === "value")
+ assert(configMap("name") === "value")
}
-
+
protected override def runTests(testName: Option[String],
reporter: Reporter, stopper: Stopper,
- includes: Set[String],
excludes: Set[String], properties: Map[String, Any]) {
- this.properties = properties;
- super.runTests(testName, reporter, stopper, includes,
excludes, properties)
+ filter: Filter, configMap:
Map[String, Any],
+ distributor: Option
[Distributor], tracker: Tracker) {
+ this.configMap = configMap
+ super.runTests(testName, reporter, stopper, filter,
configMap, distributor, tracker)
}
}
SCALA
@@ -198,54 +199,55 @@
it 'should run with ScalaCheck automatic test case generation' do
write 'src/test/scala/MySuite.scala', <<-SCALA
- import org.scalatest.prop.PropSuite
+ import org.scalatest.FunSuite
+ import org.scalatest.prop.Checkers
import org.scalacheck.Arbitrary._
import org.scalacheck.Prop._
-
- class MySuite extends PropSuite {
-
+
+ class MySuite extends FunSuite with Checkers {
+
test("list concatenation") {
val x = List(1, 2, 3)
val y = List(4, 5, 6)
assert(x ::: y === List(1, 2, 3, 4, 5, 6))
check((a: List[Int], b: List[Int]) => a.size + b.size ==
(a ::: b).size)
}
-
- test(
- "list concatenation using a test method",
- (a: List[Int], b: List[Int]) => a.size + b.size == (a :::
b).size
- )
+
+ test("list concatenation using a test method") {
+ check((a: List[Int], b: List[Int]) => a.size + b.size ==
(a ::: b).size)
+ }
}
SCALA
define('foo')
project('foo').test.invoke
project('foo').test.passed_tests.should include('MySuite')
end
-
+
it 'should fail if ScalaCheck test case fails' do
write 'src/test/scala/StringSuite.scala', <<-SCALA
- import org.scalatest.prop.PropSuite
+ import org.scalatest.FunSuite
+ import org.scalatest.prop.Checkers
import org.scalacheck.Arbitrary._
import org.scalacheck.Prop._
- class StringSuite extends PropSuite {
+ class StringSuite extends FunSuite with Checkers {
test("startsWith") {
check( (a: String, b: String) => (a+b).startsWith(a) )
}
-
+
test("endsWith") {
check( (a: String, b: String) => (a+b).endsWith(b) )
}
-
+
// Is this really always true?
test("concat") {
check( (a: String, b: String) => (a+b).length > a.length
&& (a+b).length > b.length )
}
-
+
test("substring2") {
check( (a: String, b: String) => (a+b).substring(a.length)
== b )
}
-
+
test("substring3") {
check( (a: String, b: String, c: String) =>
(a+b+c).substring(a.length, a.length+b.length) ==
b )