<commit_before>/*
 * Copyright (c) 2011-13 <NAME> 
 *
 * 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
 *
 *     http://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 shapeless

import org.junit.Test
import org.junit.Assert._

class NatTests {
  import nat._
  import ops.nat._
  
  trait Check[N <: Nat]
  def check(expected: Nat)(actually : => Check[expected.N]) {}
  
  @Test
  def testNat {
    implicitly[Succ[_1] =:= _2]
    
    implicitly[Pred.Aux[_19, _18]]
    
    def pred(n: Nat)(implicit pred : Pred[n.N]) = new Check[pred.Out] {}
    val pd1 = pred(19)
    check(18)(pd1)
    
    implicitly[Sum.Aux[_2, _3, _5]]
    
    def sum(a: Nat, b: Nat)(implicit sum : Sum[a.N, b.N]) = new Check[sum.Out] {}
    val s1 = sum(2, 3)
    check(5)(s1)

    implicitly[Diff.Aux[_5, _1, _4]]

    def diff(a: Nat, b: Nat)(implicit diff : Diff[a.N, b.N]) = new Check[diff.Out] {}
    val diff1 = diff(5, 1)
    check(4)(diff1)

    implicitly[Prod.Aux[_2, _3, _6]]
    implicitly[Prod.Aux[_4, _5, _20]]

    def prod(a: Nat, b: Nat)(implicit prod : Prod[a.N, b.N]) = new Check[prod.Out] {}
    val p1 = prod(2, 3)
    check(6)(p1)
    val p2 = prod(4, 5)
    check(20)(p2)

    implicitly[Div.Aux[_7, _2, _3]]
    implicitly[Div.Aux[_22, _11, _2]]
    implicitly[Div.Aux[_15, _3, _5]]

    def div(a: Nat, b: Nat)(implicit div : Div[a.N, b.N]) = new Check[div.Out] {}
    val d1 = div(7, 2)
    check(3)(d1)
    val d2 = div(22, 11)
    check(2)(d2)
    val d3 = div(15, 3)
    check(5)(d3)

    implicitly[Mod.Aux[_7, _2, _1]]
    implicitly[Mod.Aux[_22, _5, _2]]
    implicitly[Mod.Aux[_9, _3, _0]]

    def mod(a: Nat, b: Nat)(implicit mod : Mod[a.N, b.N]) = new Check[mod.Out] {}
    val m1 = mod(7, 2)
    check(1)(m1)
    val m2 = mod(22, 5)
    check(2)(m2)
    val m3 = mod(9, 3)
    check(0)(m3)

    implicitly[LT[_3, _5]]
    implicitly[LT[_10, _15]]
    implicitly[LTEq[_2, _2]]
    implicitly[LTEq[_2, _3]]

    def relativeToN[N <: Nat]: Unit = {
      implicitly[LT[_0, Succ[N]]]
      implicitly[LT[N, Succ[N]]]
      implicitly[LTEq[_0, N]]
      implicitly[LTEq[N, N]]
      implicitly[LTEq[N, Succ[N]]]
    }<commit_msg>Add negative tests for LT and LTEq.<commit_after>/*
 * Copyright (c) 2011-15 <NAME>
 *
 * 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
 *
 *     http://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 shapeless

import org.junit.Test
import org.junit.Assert._
import shapeless.test.illTyped

class NatTests {
  import nat._
  import ops.nat._
  
  trait Check[N <: Nat]
  def check(expected: Nat)(actually : => Check[expected.N]) {}
  
  @Test
  def testNat {
    implicitly[Succ[_1] =:= _2]
    
    implicitly[Pred.Aux[_19, _18]]
    
    def pred(n: Nat)(implicit pred : Pred[n.N]) = new Check[pred.Out] {}
    val pd1 = pred(19)
    check(18)(pd1)
    
    implicitly[Sum.Aux[_2, _3, _5]]
    
    def sum(a: Nat, b: Nat)(implicit sum : Sum[a.N, b.N]) = new Check[sum.Out] {}
    val s1 = sum(2, 3)
    check(5)(s1)

    implicitly[Diff.Aux[_5, _1, _4]]

    def diff(a: Nat, b: Nat)(implicit diff : Diff[a.N, b.N]) = new Check[diff.Out] {}
    val diff1 = diff(5, 1)
    check(4)(diff1)

    implicitly[Prod.Aux[_2, _3, _6]]
    implicitly[Prod.Aux[_4, _5, _20]]

    def prod(a: Nat, b: Nat)(implicit prod : Prod[a.N, b.N]) = new Check[prod.Out] {}
    val p1 = prod(2, 3)
    check(6)(p1)
    val p2 = prod(4, 5)
    check(20)(p2)

    implicitly[Div.Aux[_7, _2, _3]]
    implicitly[Div.Aux[_22, _11, _2]]
    implicitly[Div.Aux[_15, _3, _5]]

    def div(a: Nat, b: Nat)(implicit div : Div[a.N, b.N]) = new Check[div.Out] {}
    val d1 = div(7, 2)
    check(3)(d1)
    val d2 = div(22, 11)
    check(2)(d2)
    val d3 = div(15, 3)
    check(5)(d3)

    implicitly[Mod.Aux[_7, _2, _1]]
    implicitly[Mod.Aux[_22, _5, _2]]
    implicitly[Mod.Aux[_9, _3, _0]]

    def mod(a: Nat, b: Nat)(implicit mod : Mod[a.N, b.N]) = new Check[mod.Out] {}
    val m1 = mod(7, 2)
    check(1)(m1)
    val m2 = mod(22, 5)
    check(2)(m2)
    val m3 = mod(9, 3)
    check(0)(m3)

    implicitly[LT[_3, _5]]
    implicitly[LT[_10, _15]]
    implicitly[LTEq[_2, _2]]
    implicitly[LTEq[_2, _3]]

    illTyped(""" implicitly[LT[_5, _5]] """)
    illTyped(""" implicitly[LTEq[_6, _5]] """)

    def relativeToN[N <: Nat]: Unit = {
      implicitly[LT[_0, Succ[N]]]
      implicitly[LT[N, Succ[N]]]
      implicitly[LTEq[_0, N]]
      implicitly[LTEq[N, N]]
      implicitly[LTEq[N, Succ[N]]]

      illTyped(""" implicitly[LT[_0, N]] """)
      illTyped(""" implicitly[LT[N, N]] """)
      illTyped(""" implicitly[LTEq[_1, N]] """)
      illTyped(""" implicitly[LTEq[Succ[N], N]] """)
    }
{'fraction_non_alphanumeric': 0.16558089033659065, 'fraction_numerical': 0.04596453130655085, 'mean_word_length': 2.9734004313443565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1773415', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2250, 'n_words': 570}