You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using SuperBASIC;
  3. using System.IO;
  4. using System.Linq;
  5. namespace TestsSuperBASIC
  6. {
  7. [TestClass]
  8. public class PrebuiltTest
  9. {
  10. [TestMethod]
  11. public void TestA()
  12. {
  13. Library lib = new Library();
  14. var printer = new Mock.MockPrint();
  15. lib.AddFunction(printer, 1, "PRINT");
  16. lib.AddFunction(new SuperBASIC.Functions.MemoryLoad(), 1, "MEMLOAD");
  17. lib.AddFunction(new SuperBASIC.Functions.MemoryStore(), 2, "MEMSTORE");
  18. lib.AddFunction(new SuperBASIC.Functions.Multiply(), 2, "MULTIPLY");
  19. lib.AddFunction(new SuperBASIC.Functions.Add(), 2, "ADD");
  20. lib.AddFunction(new SuperBASIC.Functions.Compare(), 2, "COMPARE");
  21. lib.AddFunction(new SuperBASIC.Functions.JumpZero(), 2, "JZ");
  22. lib.AddFunction(new SuperBASIC.Functions.Goto(), 1, "GOTO");
  23. lib.AddFunction(new SuperBASIC.Functions.Pi(), 0, "PI");
  24. lib.AddFunction(new SuperBASIC.Functions.Euler(), 0, "EULER");
  25. Runtime r = new Runtime(lib);
  26. r.OpenFile(Directory.GetCurrentDirectory() + "\\CasDeTest\\PrebuiltTest-TestA.basic");
  27. r.Run();
  28. foreach(var (expected, received) in Enumerable.Range(1,10).Zip(printer.output))
  29. {
  30. Assert.AreEqual(expected, received);
  31. }
  32. }
  33. }
  34. }