<commit_before>defmodule Elixoids.CollisionTest do
  # Run large tests with mix test test/collision_test.exs --include large

  use ExUnit.Case, async: true
  use ExCheck

  alias Elixoids.Asteroid.Location, as: AsteroidLoc
  alias Elixoids.Bullet.Location, as: BulletLoc
  alias Elixoids.Ship.Location, as: ShipLoc
  alias Elixoids.Collision.Server, as: Collision
  alias Elixoids.World.Point

  import Elixoids.Test.Generators

  require Elixoids.Collision.Server

  @ship_radius_m 20.0

  property :check_point_generator do
    for_all p in gen_point() do
      assert p.x >= 0.0
      assert p.y >= 0.0
    end
  end

  property :check_angle_generator do
    for_all t in gen_theta() do
      assert t >= -3.2
      assert t <= 6.3
    end
  end

  property :check_multipler_generator do
    for_all m in larger_radius() do
      assert m >= 1.01
    end
  end

  property :check_frac_generator do
    for_all f in smaller_radius() do
      assert f >= 0.0
      assert f <= 0.99
    end
  end

  @tag iterations: 100, large: true
  property :bullet_in_center_of_ship_hit do
    for_all p in gen_point() do
      bullet = %BulletLoc{pos: p}
      ship = %ShipLoc{pos: p, radius: @ship_radius_m}
      assert [{:bullet_hit_ship, bullet, ship}] == Collision.collision_check([], [bullet], [ship])
    end
  end

  @tag iterations: 10000, large: true
  property :bullet_inside_ship_hit do
    for_all {ps, pb, ship_r} in point_inside_ship() do
      bullet = %BulletLoc{pos: pb}
      ship = %ShipLoc{pos: ps, radius: ship_r}
      collisions = Collision.collision_check([], [bullet], [ship])
      assert [{:bullet_hit_ship, bullet, ship}] == collisions
    end
  end

  @tag iterations: 10000, large: true
  property :bullet_misses_ship do
    for_all {ps, pb, ship_r} in point_outside_ship() do
      bullet = %BulletLoc{pos: pb}
      ship = %ShipLoc{pos: ps, radius: ship_r}
      assert [] == Collision.collision_check([], [bullet], [ship])
    end
  end
<commit_msg>More centre tests<commit_after>defmodule Elixoids.CollisionTest do
  # Run large tests with mix test test/collision_test.exs --include large

  use ExUnit.Case, async: true
  use ExCheck

  alias Elixoids.Asteroid.Location, as: AsteroidLoc
  alias Elixoids.Bullet.Location, as: BulletLoc
  alias Elixoids.Ship.Location, as: ShipLoc
  alias Elixoids.Collision.Server, as: Collision
  alias Elixoids.World.Point

  import Elixoids.Test.Generators

  require Elixoids.Collision.Server

  @ship_radius_m 20.0

  property :check_point_generator do
    for_all p in gen_point() do
      assert p.x >= 0.0
      assert p.y >= 0.0
    end
  end

  property :check_angle_generator do
    for_all t in gen_theta() do
      assert t >= -3.2
      assert t <= 6.3
    end
  end

  property :check_multipler_generator do
    for_all m in larger_radius() do
      assert m >= 1.01
    end
  end

  property :check_frac_generator do
    for_all f in smaller_radius() do
      assert f >= 0.0
      assert f <= 0.99
    end
  end

  @tag iterations: 10
  property :bullet_in_center_of_ship_hit do
    for_all p in gen_point() do
      bullet = %BulletLoc{pos: p}
      ship = %ShipLoc{pos: p, radius: @ship_radius_m}
      assert [{:bullet_hit_ship, bullet, ship}] == Collision.collision_check([], [bullet], [ship])
    end
  end

  @tag iterations: 10000, large: true
  property :bullet_inside_ship_hit do
    for_all {ps, pb, ship_r} in point_inside_ship() do
      bullet = %BulletLoc{pos: pb}
      ship = %ShipLoc{pos: ps, radius: ship_r}
      collisions = Collision.collision_check([], [bullet], [ship])
      assert [{:bullet_hit_ship, bullet, ship}] == collisions
    end
  end

  @tag iterations: 10000, large: true
  property :bullet_misses_ship do
    for_all {ps, pb, ship_r} in point_outside_ship() do
      bullet = %BulletLoc{pos: pb}
      ship = %ShipLoc{pos: ps, radius: ship_r}
      assert [] == Collision.collision_check([], [bullet], [ship])
    end
  end

  @tag iterations: 10
  property :bullet_in_center_of_asteroid_hit do
    for_all {p, r} in {gen_point(), asteroid_radius()} do
      bullet = %BulletLoc{pos: p}
      asteroid = %AsteroidLoc{pos: p, radius: r}
      assert [{:bullet_hit_asteroid, bullet, asteroid}] == Collision.collision_check([asteroid], [bullet], [])
    end
  end


{'fraction_non_alphanumeric': 0.10084230229293402, 'fraction_numerical': 0.015208235844642022, 'mean_word_length': 3.195289499509323, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '4477145', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1469, 'n_words': 421}