vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

tap.h

(1027B)


      1 #ifndef TAP_H
      2 #define TAP_H
      3 
      4 #ifdef TIS_INTERPRETER
      5 static int failures = 0;
      6 static int test_count = 0;
      7 static void plan_no_plan(void) { }
      8 
      9 static int exit_status() {
     10 	if (failures > 255)
     11 		failures = 255;
     12 	return failures;
     13 } 
     14 
     15 #define ok(e, ...) do { \
     16 	bool _e = (e); \
     17 	printf("%sok %d - ", _e ? "" : "not ", ++test_count); \
     18 	printf(__VA_ARGS__); \
     19 	printf("\n"); \
     20 	if (!_e) { \
     21 		failures++; \
     22 		printf(" Failed test (%s:%s() at line %d)\n", __FILE__, __func__, __LINE__); \
     23 	} \
     24 } while (0)
     25 
     26 #define skip_if(cond, n, ...)                          \
     27         if (cond) skip((n), __VA_ARGS__);              \
     28         else
     29 
     30 #define skip(n, ...) do { \
     31 	int _n = (n); \
     32 	while (_n--) { \
     33 		printf("ok %d # skip ", ++test_count); \
     34 		printf(__VA_ARGS__); \
     35 		printf("\n"); \
     36 	} \
     37 } while (0)
     38 
     39 #include <time.h>
     40 time_t time(time_t *p)
     41 {
     42 	static time_t value;
     43 	value++;
     44 	if (p) *p = value;
     45 	return value;
     46 }
     47 
     48 long labs(long v)
     49 {
     50 	return v > 0 ? v : -v;
     51 }
     52 
     53 #else
     54 #include <ccan/tap/tap.h>
     55 #define TIS_INTERPRETER 0
     56 #endif
     57 
     58 #endif