Skip to content

Commit 4300c8b

Browse files
authored
Update README.md
1 parent 6518048 commit 4300c8b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,30 @@ What about tests that fail by entering an infinite loop? The same technique as
435435

436436
Finally, how do you integrate TSTL testing with more conventional approaches, e.g., pytest? The file `test_tstl_regressions.py` in the examples directory shows one way. If you add all your TSTL tests of interest to a `tstl_tests` directory under the directory where `sut.py` lives, you can make pytest run all your TSTL tests. Perhaps more interestingly, this file also wraps a simple caller that forces 60 seconds of random testing to be executed by pytest, as a sanity check. You can tweak the configuration of the random testing easily -- often, adding "--swarm" is a good idea.
437437

438+
Differential Testing and References
439+
-----
440+
441+
The most important thing missing from the simplified version of the AVL harness above is the use of TSTL's powerful *differential testing* capabilities.
442+
443+
When a TSTL pool is defined as a "ref" pool, as in the full avlnew.tstl version, that means the pool will actually have *two* versions. The first works just like a normal TSTL pool. The second pool is a "copy" of the original pool, that is created by running the same Python code as the original version, with one key difference: some of the code will be automatically modified so that the "copy" can use a different underlying implementation. In the avlnew.tstl file, the code necessary for using a reference is quite small:
444+
445+
```
446+
pool: <avl> 3 OPAQUE REF
447+
448+
reference: avl.AVLTree ==> set
449+
reference: insert ==> add
450+
reference: delete ==> discard
451+
reference: find ==> __contains__
452+
453+
reference: METHOD(inorder) ==> CALL(items)
454+
reference: METHOD(display) ==> CALL(print)
455+
456+
compare: find
457+
compare: inorder
458+
```
459+
460+
The pool is marked as a "REF" pool (TSTL is not case sensitive for such designations). The actual introduction of differential testing is accomplished largely by the "reference:" parts of the harness. The first of these changes the call to the AVLTree constructor to a call to Python's built-in set implementation. The next three change the methods for AVLTrees to the appropriate methods for sets. The ones using METHOD and CALL transform methods of AVLTree into calls to functions on sets. Finally the two "compare:" lines tell TSTL that the return values for the actions find and inorder and their reference equivalents should be compared for equality, and failure should result if the results don't match.
461+
438462
TSTL and Mutation Testing
439463
-----
440464
Using the

0 commit comments

Comments
 (0)