• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/cram/test_basic.t

  1 setup common environment:
  2 
  3   $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH"
  4   $ alias ucode="$UCODE_BIN"
  5 
  6   $ for m in $BUILD_BIN_DIR/*.so; do
  7   >   ln -s "$m" "$(pwd)/$(basename $m)"; \
  8   > done
  9 
 10 check that ucode provides exepected help:
 11 
 12   $ ucode | sed 's/ucode-san/ucode/'
 13   Usage:
 14     ucode -h
 15     ucode -e "expression"
 16     ucode input.uc [input2.uc ...]
 17     ucode -c [-s] [-o output.uc] input.uc [input2.uc ...]
 18   
 19   -h
 20     Help display this help.
 21   
 22   -e "expression"
 23     Execute the given expression as ucode program.
 24   
 25   -p "expression"
 26     Like `-e` but print the result of expression.
 27   
 28   -t
 29     Enable VM execution tracing.
 30   
 31   -g interval
 32     Perform periodic garbage collection every `interval` object
 33     allocations.
 34   
 35   -S
 36     Enable strict mode.
 37   
 38   -R
 39     Process source file(s) as raw script code (default).
 40   
 41   -T[flag,flag,...]
 42     Process the source file(s) as templates, not as raw script code.
 43     Supported flags: no-lstrip (don't strip leading whitespace before
 44     block tags), no-rtrim (don't strip trailing newline after block tags).
 45   
 46   -D [name=]value
 47     Define global variable. If `name` is omitted, a JSON dictionary is
 48     expected with each property becoming a global variable set to the
 49     corresponding value. If `name` is specified, it is defined as global
 50     variable set to `value` parsed as JSON (or the literal `value` string
 51     if JSON parsing fails).
 52   
 53   -F [name=]path
 54     Like `-D` but reading the value from the file in `path`. The given
 55     file must contain a single, well-formed JSON dictionary.
 56   
 57   -U name
 58     Undefine the given global variable name.
 59   
 60   -l [name=]library
 61     Preload the given `library`, optionally aliased to `name`.
 62   
 63   -L pattern
 64     Prepend given `pattern` to default library search paths. If the pattern
 65     contains no `*`, it is added twice, once with `/*.so` and once with
 66     `/*.uc` appended to it.
 67   
 68   -c[flag,flag,...]
 69     Compile the given source file(s) to bytecode instead of executing them.
 70     Supported flags: no-interp (omit interpreter line), interp=... (over-
 71     ride interpreter line with ...), dynlink=... (force import from ... to
 72     be treated as shared extensions loaded at runtime).
 73   
 74   -o path
 75     Output file path when compiling. If omitted, the compiled byte code
 76     is written to `./uc.out`. Only meaningful in conjunction with `-c`.
 77   
 78   -s
 79     Omit (strip) debug information when compiling files.
 80     Only meaningful in conjunction with `-c`.
 81   
 82 
 83 check that ucode prints greetings:
 84 
 85   $ ucode -e "print('hello world')"
 86   hello world (no-eol)
 87 
 88 check that ucode provides proper error messages:
 89 
 90   $ touch lib.uc; ucode -l lib
 91   Require either -e/-p expression or source file
 92   [1]
 93 
 94   $ ucode -l foo -e ' '
 95   Runtime error: No module named 'foo' could be found
 96   
 97   [1]
 98 
 99   $ touch moo; ucode -l foo moo
100   Runtime error: No module named 'foo' could be found
101   
102   [1]
103 
104 check that ucode can load fs module:
105 
106   $ ucode -l fs
107   Require either -e/-p expression or source file
108   [1]
109 
110   $ ucode -l fs -e ' '
111 
112   $ touch moo; ucode -l fs moo

This page was automatically generated by LXR 0.3.1.  •  OpenWrt