SFTtech / nyan

Typesafe hierarchical key-value database with inheritance and dynamic patching :smiley_cat:
Other
208 stars 29 forks source link

Tests #70

Open MaanooAk opened 4 years ago

MaanooAk commented 4 years ago

A suggestion for testing (what I am using in jnyan):

tests
├── 001
│   ├── main.nyan
│   └── sim
│       ├── 001.txt
│       └── 002.txt
└── 002
     ├── engine.nyan
     ├── main.nyan
     └── sim
         ├── 001.txt
         └── 002.txt

Where the root folders are test cases with loaded file being the main.nyan (which may include import statements) and in the sim (= simulation) folders there are files with commands in order to simulate a scenario. Every line is command, mainly assert like commands but also execution of patches.

// optionally set a namespace
namespace main

// asserts
Barracks creates    == [main.Jedi, main.Clone]
Barracks hp         == 4000
Barracks model      == ./models/m1.dat

// assert number of members
Unit     # 3
Infantry # 3

Jedi   hp  == 300
Master hp  == 480

// apply a patch
patch ArmorUpgrade

Jedi   hp  == 310
Master hp  == 490

Source: jnyan/src/test/resources/tests/000

TheJJ commented 4 years ago

Very good idea! We should do the same here :)

I'd adapt the syntax a slight little bit though: instead of Barracks creates I'd use Barracks.creates or Barracks:creates. That should also simplify parsing a bit, because space # then is always # and member access is uniquely formatted.

TheJJ commented 4 years ago

We should also add a syntax to refer to points in time, and to create transactions with >1 patches.

heinezen commented 4 years ago

Good idea!

This could be extended with API-specific tests that can assert whether our state transitions for game entities are correct and whether AvalabilityRequirement and Condition work like they should.