1/*
2 * Copyright 2001-2011 Artima, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.scalatest
17
18import org.scalatest.events.Event
19import org.scalatest.events.TestSucceeded
20
21class UseAsFunctionSpec extends FreeSpec {
22
23  "You should be able to use the following as a function after moving to a deprecated implicit conversion:" - {
24
25    "a Reporter" in {
26      def takesFun(fun: Event => Unit) {}
27      class MyReporter extends Reporter {
28        def apply(e: Event) {}
29      }
30      takesFun(new MyReporter) // If it compiles, the test passes
31    }
32
33    "a Rerunner" in {
34      def takesFun(fun: (Reporter, Stopper, Filter, Map[String, Any], Option[Distributor], Tracker, ClassLoader) => Unit) {}
35      class MyRerunner extends Rerunner {
36        def apply(reporter: Reporter, stopper: Stopper, filter: Filter,
37            configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker, loader: ClassLoader) {}
38      }
39      takesFun(new MyRerunner) // If it compiles, the test passes
40    }
41
42    "a Stopper" in {
43      def takesFun(fun: () => Boolean) {}
44      class MyStopper extends Stopper {
45        override def apply() = true
46      }
47      takesFun(new MyStopper) // If it compiles, the test passes
48    }
49
50    "a Distributor" in {
51      def takesFun(fun: (Suite, Tracker) => Unit) {}
52      class MyDistributor extends Distributor {
53        def apply(suite: Suite, tracker: Tracker) {}
54      }
55      takesFun(new MyDistributor) // If it compiles, the test passes
56    }
57  }
58}
59