<commit_before>/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2004, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
** $Id$
\*                                                                      */

package scala.testing;

/** some simple methods to support unit testing with assertions
**  to contain more JUnit style assertions which use Scala's features.
*/
object UnitTest {

  import java.lang.System;

  def message_passedOK:Unit = {
    System.out.println("passed ok")
  }

  def message_failed( actual:String, expected:String ):Unit = {
    System.out.print("failed! we got");
    System.out.print( "\""+ actual +"\"" );
    System.out.println(" but expected " + expected)
  }

  def assertEquals[a]( actual: a, expected: a ):Unit =
    if( actual == expected )
        message_passedOK
    else
	message_failed( actual.toString(), expected.toString() );

  def assertNotEquals[a]( actual: a, expected: a ):Unit =
    if( actual != expected )
        message_passedOK
    else
	message_failed( actual.toString(), "something != "+expected.toString() );

  def test[a]( def doit: a, expected: a ):Unit = assertEquals( doit, expected );

} // unitTest<commit_msg>more flexible reporting<commit_after>/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2004, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
** $Id$
\*                                                                      */

package scala.testing;

/** some simple methods to support unit testing with assertions
**  to contain more JUnit style assertions which use Scala's features.
*/
object UnitTest {

  class Report( report_ok:()=>Unit, report_fail:(String,String)=>Unit ) {
    def ok:Unit = report_ok();
    def fail( actual:String, expected:String ):Unit =
      report_fail( actual, expected );
  }

  var report = new Report(
    { () => Console.println("passed ok") },
    { (actual:String, expected:String) =>
        Console.print("failed! we got");
         Console.print( "\""+ actual +"\"" );
         Console.println(" but expected \"" + expected + "\"") });

  def setReporter( r:Report ) = {
    this.report = r;
  }

  def assertSimilar( actual:Similarity , expected: Similarity ):Unit =
    if( actual.similar( expected ) )
        report.ok
    else
	report.fail( actual.toString(), expected.toString() );

  def assertEquals[a]( actual: a, expected: a ):Unit =
    if( actual == expected )
        report.ok
    else
	report.fail( actual.toString(), expected.toString() );

  def assertNotEquals[a]( actual: a, expected: a ):Unit =
    if( actual != expected )
        report.ok
    else
	report.fail( actual.toString(), "x != "+expected.toString() );

  //def test[a]( def doit: a, expected: a ):Unit = assertEquals( doit, expected );

} // unitTest
{'fraction_non_alphanumeric': 0.14198428862379983, 'fraction_numerical': 0.004655222577829503, 'mean_word_length': 1.487698986975398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6871032', 'n_tokens_mistral': 946, 'n_tokens_neox': 895, 'n_words': 218}