Comments (1)
Here is a neat function that will print the expression under test, the expected value and the actual value
import strformat, strutils, macros
template check*(exp:untyped, expected: untyped, failureMsg:string="failed", indent:uint=0): void =
let indentationStr = repeat(' ', indent)
let expStr: string = astToStr(exp)
var msg: string
if exp != expected:
msg = indentationStr & expStr & " .. " & failureMsg & "\n (expected: " & astToStr(expected) & ", actual: " & $exp & ")"
else:
msg = indentationStr & expStr & " .. passed"
print(msg) # replace this by your print function
check(1+2, 3) # "1 + 2 .. passed"
check(1+1, 3) # "1 + 1 .. failed (expected: 3, actual: 2)"
from playdate-nim.
Related Issues (20)
- Build for device OS 2.0 error: undefined reference to `_fini' HOT 1
- Does not compile with Nim 2.0.0 HOT 8
- Runtime crashes halt simulator without any indication of problems HOT 6
- Feature: Basic Lua interop HOT 9
- Implement Std/random HOT 3
- api aliases HOT 2
- implement os module HOT 2
- LCD:Sprite.setImage crashes when invoked multiple times HOT 6
- Use `projectName()` instead of static PDX name? HOT 4
- Conflicting types HOT 4
- player volume: double promotion warning HOT 2
- Unclear naming requirement for main entrypoint nim file HOT 2
- arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.specs': No such file or directory HOT 3
- When importing std/logging, device compilation fails HOT 1
- Mac device Debug builds for device profiling HOT 1
- How to deal with "declared lock level is 0, but real lock level is <unknown> [LockLevel]" HOT 3
- Playdate memory allocator HOT 6
- Update the recommended VSCode Nim extension in the README HOT 1
- sigabrt: double free when calling file.close()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playdate-nim.