<commit_before>package asmcup.runtime;

import asmcup.vm.VM;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

public class RobotTest {
	Robot robot = null;

	@Before
	public void setUp() {
		robot = new Robot(42);
		robot.position(42, 21);
	}

	@Test
	public void testAccelerometer() {
		World world = generateEmptyWorld((int) robot.getX(), (int) robot.getY(), 50);
		// Read Accelerometer
		VM vm = robot.getVM();
		vm.push8(Robot.IO_ACCELEROMETER);
		vm.setIO(true);
		robot.handleIO(world);

		// We did not drive, so we should expect 0 values.
		float x = vm.popFloat();
		float y = vm.popFloat();
		assertEquals(0, x, 0.001f);
		assertEquals(0, y, 0.001f);
		assertEquals(x, y, 0.001f);

		// Drive a little bit
		robot.setMotor(1.0f);
		robot.setSteer(0.5f);
		robot.tickHardware(world);


		vm.push8(Robot.IO_ACCELEROMETER);
		vm.setIO(true);
		robot.handleIO(world);

		// We drove, so we should not expect 0 values.
		x = vm.popFloat();
		y = vm.popFloat();
		assertNotEquals(0f, x, 0.001f);
		assertNotEquals(0f, y, 0.001f);
		assertNotEquals(x, y, 0.001f);
	}

	@Test
	public void testSteer() {
		World world = new World();
		float previous = robot.getFacing();
		robot.tickSteer(world);
		assertEquals("Robot steered", previous, robot.getFacing(), 0.0001f);

		robot.setSteer(1.0f);
		robot.tickSteer(world);
		assertTrue("Robot did not steer.", previous < robot.getFacing());
	}

	@Test
	public void testMotor() {
		World world = generateEmptyWorld((int) robot.getX(), (int) robot.getY(), 30);
		float x = robot.getX();
		float y = robot.getY();<commit_msg>Fixed non-deterministic test failure (#138)<commit_after>package asmcup.runtime;

import asmcup.vm.VM;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

public class RobotTest {
	Robot robot = null;

	@Before
	public void setUp() {
		robot = new Robot(42);
		robot.position(42, 21);
	}

	@Test
	public void testAccelerometer() {
		World world = generateEmptyWorld((int) robot.getX(), (int) robot.getY(), 50);
		// Read Accelerometer
		VM vm = robot.getVM();
		vm.push8(Robot.IO_ACCELEROMETER);
		vm.setIO(true);
		robot.handleIO(world);

		// We did not drive, so we should expect 0 values.
		float x = vm.popFloat();
		float y = vm.popFloat();
		assertEquals(0, x, 0.001f);
		assertEquals(0, y, 0.001f);
		assertEquals(x, y, 0.001f);

		// Drive a little bit
		robot.setMotor(1.0f);
		robot.setSteer(0.5f);
		robot.tickHardware(world);


		vm.push8(Robot.IO_ACCELEROMETER);
		vm.setIO(true);
		robot.handleIO(world);

		// We drove, so we should not expect 0 values.
		x = vm.popFloat();
		y = vm.popFloat();
		assertNotEquals(0f, x, 0.001f);
		assertNotEquals(0f, y, 0.001f);
		assertNotEquals(x, y, 0.001f);
	}

	@Test
	public void testSteer() {
		World world = new World();
		float previous = robot.getFacing();
		robot.tickSteer(world);
		assertEquals("Robot steered", previous, robot.getFacing(), 0.0001f);

		robot.setSteer(1.0f);
		robot.tickSteer(world);
		assertTrue("Robot did not steer.", previous < robot.getFacing());
	}

	@Test
	public void testMotor() {
		World world = generateEmptyWorld((int) robot.getX(), (int) robot.getY(), 50);
		float x = robot.getX();
		float y = robot.getY();
{'fraction_non_alphanumeric': 0.14988558352402745, 'fraction_numerical': 0.031178489702517163, 'mean_word_length': 4.024425287356322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3085441', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1307, 'n_words': 307}