public void TestCalculation() { TestSimulator.TestCommand("mov r0, #0xFF, #0xc"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0xff00); TestSimulator.TestCommand("mov r0, #77"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 77); TestSimulator.TestCommand("mov r0, #0x3f"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0x3f); TestSimulator.TestCommand("mov r1, #2"); TestSimulator.TestCommand("mov r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 2); TestSimulator.TestCommand("mov r1, r1, lsl r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R1), 8); TestSimulator.TestCommand("mov r0, r0, lsl #2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 8); TestSimulator.TestCommand("mvn r0, #0"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), -1); TestSimulator.TestCommand("movs r0, #0"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("mvns r0, #0"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), -1); Assert.AreEqual(GetConditionFlags(), 8); TestSimulator.TestCommand("mov r1, #8"); TestSimulator.TestCommand("movs r0, r1, lsl#29"); Assert.AreEqual(GetConditionFlags(), 6); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #3"); TestSimulator.TestCommand("mov r1, #5"); TestSimulator.TestCommand("mov r2, #0x4"); TestSimulator.TestCommand("mov r3, r2, lsl#28"); TestSimulator.TestCommand("add r4, r0, #7"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 10); TestSimulator.TestCommand("adds r4, r0, #7"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 10); Assert.AreEqual(GetConditionFlags(), 0); TestSimulator.TestCommand("add r4, r3, r3"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), int.MinValue); TestSimulator.TestCommand("adds r4, r3, r3"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), int.MinValue); Assert.AreEqual(GetConditionFlags(), 9); TestSimulator.TestCommand("adds r4, r1, r2, lsl#2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 21); Assert.AreEqual(GetConditionFlags(), 0); TestSimulator.TestCommand("add r4, r1, r1, lsl#2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 25); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #3"); TestSimulator.TestCommand("mov r1, #5"); TestSimulator.TestCommand("mov r2, #0x4"); TestSimulator.TestCommand("mov r3, r2, lsl#28"); TestSimulator.TestCommand("sub r4, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), -2); TestSimulator.TestCommand("subs r4, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), -2); Assert.AreEqual(GetConditionFlags(), 10); TestSimulator.TestCommand("sub r4, r0, #3"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 0); TestSimulator.TestCommand("subs r4, r0, #3"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 0); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("rsb r4, r1, r2, lsl#2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 11); TestSimulator.TestCommand("rsbs r4, r2, r0"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), -1); Assert.AreEqual(GetConditionFlags(), 10); }
/*--------------------------------------------------------------- * GAME STATE INIATIALISATIONS * ---------------------------------------------------------------*/ /*************************************************************** * Called on Scene initialization **************************************************************/ void Awake() { if (TestSimulator.isDeveloping) { TestSimulator.initTestEnvironment(GameState.CHARACTER_CREATION); } AssetLoader.loadStaticAssets(GameState.CHARACTER_CREATION); partyPanels = new List <PartyPanel>(); initClassData(); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #0"); TestSimulator.TestCommand("mov r1, #1"); TestSimulator.TestCommand("mov r5, r1, lsl#16"); TestSimulator.TestCommand("mov r6, r1, lsl#20"); TestSimulator.TestCommand("mov r2, #2"); TestSimulator.TestCommand("mvn r7, #0"); TestSimulator.TestCommand("mul r0, r5, r5"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0); TestSimulator.TestCommand("mul r0, r2, r2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 4); TestSimulator.TestCommand("mul r0, r5, r2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0x20000); TestSimulator.TestCommand("mla r0, r5, r2, r2"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R0), 0x20002); TestSimulator.TestCommand("smull r3, r4, r6, r6"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R3), 0); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 0x100); TestSimulator.TestCommand("mov r3, #2"); TestSimulator.TestCommand("mov r4, #2"); TestSimulator.TestCommand("smlal r3, r4, r6, r6"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R3), 2); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R4), 0x102); TestSimulator.TestCommand("mov r3, #0"); TestSimulator.TestCommand("mov r4, #0"); TestSimulator.TestCommand("smlal r3, r4, r6, r7"); Assert.AreEqual((uint)TestSimulator.ArmCore.GetRegValue(ERegister.R3), 0xfff00000); Assert.AreEqual((uint)TestSimulator.ArmCore.GetRegValue(ERegister.R4), 0xffffffff); TestSimulator.TestCommand("mov r0, #0xFF, 4"); TestSimulator.TestCommand("mvn r1, #0"); TestSimulator.TestCommand("smull r2, r3, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 0x1000000); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R3), 0x0); TestSimulator.TestCommand("umull r2, r3, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 0x1000000); Assert.AreEqual((uint)TestSimulator.ArmCore.GetRegValue(ERegister.R3), 0xfeffffff); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #3"); TestSimulator.TestCommand("mov r1, #5"); TestSimulator.TestCommand("and r2, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 1); TestSimulator.TestCommand("eor r2, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 6); TestSimulator.TestCommand("orr r2, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 7); TestSimulator.TestCommand("bic r2, r0, r1"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 2); TestSimulator.TestCommand("bic r2, r1, r0"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 4); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #7"); TestSimulator.TestCommand("mov r2, #0"); TestSimulator.TestCommand("mov r1, #0x1"); TestSimulator.TestCommand("mov r1, r1, lsl#16"); TestSimulator.TestCommand("str r0, [r1, #0x100]!"); TestSimulator.TestCommand("ldr r2, [r1]"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R1), 0x10100); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 7); TestSimulator.TestCommand("str r0, [r1], #0x100"); TestSimulator.TestCommand("ldr r2, [r1]"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R1), 0x10200); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 0); TestSimulator.TestCommand("str r0, [r1, r0]"); TestSimulator.TestCommand("ldr r2, [r1, r0]"); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R1), 0x10200); Assert.AreEqual(TestSimulator.ArmCore.GetRegValue(ERegister.R2), 7); }
public void TestCalculation() { TestSimulator.TestCommand("mov r0, #3"); TestSimulator.TestCommand("mov r1, #2"); TestSimulator.TestCommand("mvn r2, #2"); TestSimulator.TestCommand("cmp r0, #3"); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("cmp r0, r0"); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("cmn r0, r2"); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("cmn r0, r1"); Assert.AreEqual(GetConditionFlags(), 0); TestSimulator.TestCommand("tst r1, r2"); Assert.AreEqual(GetConditionFlags(), 4); TestSimulator.TestCommand("teq r1, r1"); Assert.AreEqual(GetConditionFlags(), 4); }
public AssertRegisterStateImpl(TestSimulator sim) : base(sim) { _sim = sim; }
public void Test_PriceAndGreeks() { List <TestVector> testVectors = new List <TestVector> { new TestVector { quoteDate = DateTime.Parse("10/01/2015"), underlyingLast = 1921.42, riskFreeRate = 0.024, dividendYield = 0.00, //0.018, expiration = DateTime.Parse("10/16/2015"), strike = 1845, isPut = false, bid = 85.80, ask = 90.00, // impliedVol = 0.2538, delta = 0.798, gamma = 0.0029, theta = -351.149, vega = 107.226 // from historical data impliedVol = 0.23699109, delta = 0.81315737, gamma = 0.00291045, theta = -337.13293066, vega = 104.57753610 }, new TestVector { quoteDate = DateTime.Parse("10/01/2015"), underlyingLast = 1921.42, riskFreeRate = 0.024, dividendYield = 0.00, //0.018, expiration = DateTime.Parse("10/16/2015"), strike = 1980, isPut = false, bid = 6.80, ask = 8.20, // impliedVol = 0.177, delta = 0.2018, gamma = 0.0042, theta = -242.777, vega = 107.183 // from historical data impliedVol = 0.17021597, delta = 0.20473715, gamma = 0.00428357, theta = -238.35915581, vega = 110.54824762 }, new TestVector { quoteDate = DateTime.Parse("10/01/2015"), underlyingLast = 1921.42, riskFreeRate = 0.024, dividendYield = 0.00, //0.018, expiration = DateTime.Parse("10/16/2015"), strike = 1845, isPut = true, bid = 9.40, ask = 11.60, // impliedVol = 0.2472, delta = -0.1961, gamma = 0.0029, theta = -330.323, vega = 105.344 // from historical data impliedVol = 0.24491080, delta = -0.19423270, gamma = 0.00288422, theta = -310.13506432, vega = 107.09810115 }, new TestVector { quoteDate = DateTime.Parse("10/01/2015"), underlyingLast = 1921.42, riskFreeRate = 0.024, dividendYield = 0.00, //0.018, expiration = DateTime.Parse("10/16/2015"), strike = 1980, isPut = true, bid = 63.20, ask = 67.90, // impliedVol = 0.1734, delta = -0.8032, gamma = 0.0042, theta = -227.891, vega = 105.562 // from historical data impliedVol = 0.18275260, delta = -0.77809756, gamma = 0.00418151, theta = -220.34075530, vega = 115.86234498 }, new TestVector { quoteDate = DateTime.Parse("01/04/2016"), underlyingLast = 1993.680054, riskFreeRate = 0.024, dividendYield = 0.00, expiration = DateTime.Parse("02/26/2016"), strike = 300, isPut = false, bid = 1695.00, ask = 1695.00, //impliedVol = 1.9811, delta = 0.9973, gamma = 0.000004, theta = -0.064148, vega = 0.047015 // from historical data impliedVol = 1.72686453, delta = 0.99934408, gamma = 0.00000174, theta = -17.45819022, vega = 1.73456198 }, }; foreach (var testVector in testVectors) { //--- create data source for underlying Dictionary <DataSourceParam, string> underlyingInfos = new Dictionary <DataSourceParam, string> { { DataSourceParam.name, "S&P 500 Index" } }; List <Bar> underlyingBars = new List <Bar> { new Bar( "SPX", testVector.quoteDate, testVector.underlyingLast, testVector.underlyingLast, testVector.underlyingLast, testVector.underlyingLast, 100, true, default(double), default(double), default(long), default(long), false, default(DateTime), default(double), default(bool)) }; DataSource underlyingDataSource = new DataSourceFromBars(underlyingBars, underlyingInfos); //--- create data source for option Dictionary <DataSourceParam, string> optionInfos = new Dictionary <DataSourceParam, string> { { DataSourceParam.name, "S&P 500 Index Options" }, { DataSourceParam.optionUnderlying, "SPX" } }; List <Bar> optionBars = new List <Bar> { new Bar( "SPX_Option", testVector.quoteDate, default(double), default(double), default(double), default(double), default(long), false, testVector.bid, testVector.ask, 100, 100, true, testVector.expiration, testVector.strike, testVector.isPut) }; DataSource optionDataSource = new DataSourceFromBars(optionBars, optionInfos); //--- run test TuringTrader.Simulator.SimulatorCore callSim = new TestSimulator( new List <DataSource> { underlyingDataSource, optionDataSource }, testVector.riskFreeRate, testVector.dividendYield, testVector.impliedVol, testVector.delta, testVector.gamma, testVector.theta, testVector.vega ); } }