<commit_before>/*
 * Copyright © 2016 Schlichtherle IT Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package global.namespace.neuron.di.scala.test

import global.namespace.neuron.di.scala.CachingStrategy._
import global.namespace.neuron.di.scala.test.WireMacroSpec._
import global.namespace.neuron.di.scala.{Caching, Neuron, wire}
import org.scalatest.FeatureSpec
import org.scalatest.Matchers._

class WireMacroSpec extends FeatureSpec {

  feature("Synapse methods in neuron and non-neuron types can be auto-wired using the `wire` macro") {

    scenario("A[Int]") {
      val foo = 1
      val a = wire[A[Int]]
      a.foo shouldBe foo
    }

    scenario("A[String]") {
      def foo = new String("foo")
      val a = wire[A[String]]
      a.foo shouldBe foo
      a.foo shouldNot be theSameInstanceAs a.foo
    }

    scenario("A1") {
      def foo = new String("foo")
      val a1 = wire[A1]
      a1.foo shouldBe foo
      a1.foo should be theSameInstanceAs a1.foo
    }

    scenario("A2") {
      def foo = new String("foo")
      val a2 = wire[A2]
      a2.foo shouldBe foo
      a2.foo should be theSameInstanceAs a2.foo
    }

    scenario("ABC[Int]") {
      val foo = 1
      val bar = 2
      def baz(abc: ABC[Int]) = abc.foo + abc.bar
      val abc = wire[ABC[Int]]
      abc.foo shouldBe foo
      abc.bar shouldBe bar
      abc.baz shouldBe baz(abc)
    }

    scenario("ABC[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      def baz(abc: ABC[String]) = abc.foo + abc.bar
      val abc = wire[ABC[String]]
      abc.foo shouldBe foo
      abc.foo shouldNot be theSameInstanceAs abc.foo
      abc.bar shouldBe bar
      abc.bar shouldNot be theSameInstanceAs abc.bar
      abc.baz shouldBe baz(abc)
      abc.baz shouldNot be theSameInstanceAs abc.baz
    }

    scenario("ABC1[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      val baz = (abc: ABC1[String]) => abc.foo + abc.bar
      val abc1 = wire[ABC1[String]]
      abc1.foo shouldBe foo
      abc1.foo should be theSameInstanceAs abc1.foo
      abc1.bar shouldBe bar
      abc1.bar should be theSameInstanceAs abc1.bar
      abc1.baz shouldBe baz(abc1)
      abc1.baz should be theSameInstanceAs abc1.baz
    }

    scenario("ABC2[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      val baz = (abc: ABC2[String]) => abc.foo + abc.bar
      val abc2 = wire[ABC2[String]]
      abc2.foo shouldBe foo
      abc2.foo should be theSameInstanceAs abc2.foo
      abc2.bar shouldBe bar
      abc2.bar should be theSameInstanceAs abc2.bar
      abc2.baz shouldBe baz(abc2)
      abc2.baz should be theSameInstanceAs abc2.baz
    }
  }
}<commit_msg>Improves test coverage of wire macro.<commit_after>/*
 * Copyright © 2016 Schlichtherle IT Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package global.namespace.neuron.di.scala.test

import java.util.function.Supplier

import global.namespace.neuron.di.scala.CachingStrategy._
import global.namespace.neuron.di.scala.test.WireMacroSpec._
import global.namespace.neuron.di.scala.{Caching, Neuron, wire}
import org.scalatest.FeatureSpec
import org.scalatest.Matchers._

class WireMacroSpec extends FeatureSpec {

  feature("Synapse methods in neuron and non-neuron types can be auto-wired using the `wire` macro") {

    scenario("A[Int]") {
      val foo = 1
      val a = wire[A[Int]]
      a.foo shouldBe foo
    }

    scenario("A[String]") {
      def foo = new String("foo")
      val a = wire[A[String]]
      a.foo shouldBe foo
      a.foo shouldNot be theSameInstanceAs a.foo
    }

    scenario("A1") {
      def foo = new String("foo")
      val a1 = wire[A1]
      a1.foo shouldBe foo
      a1.foo should be theSameInstanceAs a1.foo
    }

    scenario("A2") {
      def foo = new String("foo")
      val a2 = wire[A2]
      a2.foo shouldBe foo
      a2.foo should be theSameInstanceAs a2.foo
    }

    scenario("ABC[Int]") {
      val foo = 1
      val bar = 2
      def baz(abc: ABC[Int]) = abc.foo + abc.bar
      val abc = wire[ABC[Int]]
      abc.foo shouldBe foo
      abc.bar shouldBe bar
      abc.baz shouldBe baz(abc)
    }

    scenario("ABC[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      def baz(abc: ABC[String]) = abc.foo + abc.bar
      val abc = wire[ABC[String]]
      abc.foo shouldBe foo
      abc.foo shouldNot be theSameInstanceAs abc.foo
      abc.bar shouldBe bar
      abc.bar shouldNot be theSameInstanceAs abc.bar
      abc.baz shouldBe baz(abc)
      abc.baz shouldNot be theSameInstanceAs abc.baz
    }

    scenario("ABC1[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      val baz = (abc: ABC1[String]) => abc.foo + abc.bar
      val abc1 = wire[ABC1[String]]
      abc1.foo shouldBe foo
      abc1.foo should be theSameInstanceAs abc1.foo
      abc1.bar shouldBe bar
      abc1.bar should be theSameInstanceAs abc1.bar
      abc1.baz shouldBe baz(abc1)
      abc1.baz should be theSameInstanceAs abc1.baz
    }

    scenario("ABC2[String]") {
      def foo = new String("foo")
      def bar = new String("bar")
      val baz = (abc: ABC2[String]) => abc.foo + abc.bar
      val abc2 = wire[ABC2[String]]
      abc2.foo shouldBe foo
      abc2.foo should be theSameInstanceAs abc2.foo
      abc2.bar shouldBe bar
      abc2.bar should be theSameInstanceAs abc2.bar
      abc2.baz shouldBe baz(abc2)
      abc2.baz should be theSameInstanceAs abc2.baz
    }

    scenario("Supplier[String]") {
      def get = "Hello world!"
      val supplier = wire[Supplier[String]]
      supplier.get shouldBe "Hello world!"
    }
  }
}
{'fraction_non_alphanumeric': 0.09946316731285416, 'fraction_numerical': 0.01521025946913212, 'mean_word_length': 2.659028914348063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '20963', 'n_tokens_mistral': 2194, 'n_tokens_neox': 2167, 'n_words': 667}