btcs

bitcoin script parser/evaluator/compiler/decompiler
git clone git://jb55.com/btcs
Log | Files | Refs | README | LICENSE

commit 75976c7dd4a4f577d9472888ce41e613c73de32c
parent 6d8611f55b196ca7632b774290c313d0da4581c0
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 26 Oct 2017 11:47:43 -0700

val: smallintval macro

Diffstat:
Mop.h | 2++
Mtest.c | 6++----
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/op.h b/op.h @@ -329,6 +329,8 @@ enum opcode op_tokenize(char *); void val_print(struct val); const char * val_name(struct val); +#define smallintval(n) ((struct val){ .is_big = 0, .type = VT_INT, .val = n }) + static inline void stack_push_val(struct stack *stack, struct val val) { #if 0 diff --git a/test.c b/test.c @@ -35,8 +35,7 @@ TEST(test_simple) { script_eval(script, stack); - struct val one = { .is_big = 0, .type = VT_INT, .val = 1 }; - stack_push_val(expected, one); + stack_push_val(expected, smallintval(1)); ok_stacks_equal(stack, expected, "test_simple"); } @@ -47,8 +46,7 @@ TEST(test_nip) { script_eval(script, stack); - struct val two = { .is_big = 0, .type = VT_INT, .val = 2 }; - stack_push_val(expected, two); + stack_push_val(expected, smallintval(2)); ok_stacks_equal(stack, expected, "test_nip"); }