about summary refs log blame commit diff stats
path: root/transect/ex3.k2
blob: 6315139682d6a82b4c1b619c3eb1003a2495df14 (plain) (tree)





















                                                                  
# add the first 10 numbers, and return the result in the exit code

fn main [
  var result/EBX : int
  result/EBX <- copy 0
  var counter/ECX : int
  counter/ECX <- copy 1
  {
    compare counter/ECX, 10
    break-if >
    result/EBX <- add counter/ECX
    counter/ECX <- add 1
    loop
  }
  call exit, 1
]

fn exit x : int [
  code/EBX <- copy x
  code/EAX <- copy 1/exit
  syscall
]
span class="cpf"><glib.h> #include <stdarg.h> #include <stddef.h> #include <setjmp.h> #include <cmocka.h> #include <stdlib.h> #include <string.h> #include <stabber.h> #include <expect.h> #include "proftest.h" void message_send(void **state) { prof_connect(); prof_input("/msg somejid@someserver.com Hi there"); assert_true(stbbr_received( "<message id='*' to='somejid@someserver.com' type='chat'>" "<body>Hi there</body>" "</message>" )); assert_true(prof_output_regex("me: .+Hi there")); } void message_receive_console(void **state) { prof_connect(); stbbr_send( "<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>" "<body>How are you?</body>" "</message>" ); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); } void message_receive_chatwin(void **state) { prof_connect(); prof_input("/msg someuser@chatserv.org"); assert_true(prof_output_exact("someuser@chatserv.org")); stbbr_send( "<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>" "<body>How are you?</body>" "</message>" ); assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?")); }