<commit_before>package async

import org.scalatest.FunSuite

import scala.async.Async._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.util.{Failure, Success}

class AsyncTest extends FunSuite {
  test("async") {
    val future: Future[Int] = async {
      val futureOne: Future[Int] = async { 1 }
      val futureTwo: Future[Int] = async { 2 }
      await(futureOne) + await(futureTwo)
    }
    future onComplete {
      case Success(result) => assert(result == 3)
      case Failure(failure) => throw failure
    }
  }

  test("async rest") {
    val joke = Await.result(AsyncRest.asyncJoke, 3 seconds)
    assertJoke(joke)
  }

  test("akka rest") {
    val joke = Await.result(AkkaRest.asyncJoke, 3 seconds)
    assertJoke(joke)
  }

  private def assertJoke(joke: String) = {
    assert(!joke.isEmpty)
    println(joke)
  }
}<commit_msg>refactored unit test for async and akka rest calls<commit_after>package async

import org.scalatest.FunSuite

import scala.async.Async._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.util.{Failure, Success}

class AsyncTest extends FunSuite {
  test("async") {
    val future: Future[Int] = async {
      val futureOne: Future[Int] = async { 1 }
      val futureTwo: Future[Int] = async { 2 }
      await(futureOne) + await(futureTwo)
    }
    future onComplete {
      case Success(result) => assert(result == 3)
      case Failure(failure) => throw failure
    }
  }

  test("async rest") {
    assertJoke(AsyncRest.asyncJoke)
  }

  test("akka rest") {
    assertJoke(AkkaRest.asyncJoke)
  }

  private def assertJoke(future: Future[String]) = {
    future onComplete {
      case Success(joke) => assert(!joke.isEmpty)
      case Failure(failure) => throw failure
    }
  }
}
{'fraction_non_alphanumeric': 0.11395101171458999, 'fraction_numerical': 0.004259850905218318, 'mean_word_length': 3.4526066350710902, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3088289', 'n_tokens_mistral': 620, 'n_tokens_neox': 602, 'n_words': 140}