Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: d0eb5328c1
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 113 lines (90 sloc) 1.72 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
#!perl

# Copyright (C) 2004-2006, The Parrot Foundation.

# the following lines re-execute this as a tcl script
# the \ at the end of these lines makes them a comment in tcl \
use lib qw(lib); # \
use Tcl::Test; #\
__DATA__

source lib/test_more.tcl

plan 15

eval_is {
 set a 2
 incr a
 set a
} 3 simple

eval_is {
 set a 1
 incr a 5
 set a
} 6 offset

eval_is {
 set a 2
 incr a -1
 set a
} 1 {negative offset}

eval_is {
 set a 1
 incr a
} 2 {return value}

eval_is {
 set a -2
 incr a
 set a
} -1 {negative base}


eval_is {
 set a 2
 incr a +3
 set a
} 5 {explicit positive offset}

eval_is {
 set a 1
 incr a 3 2
 set a
} {wrong # args: should be "incr varName ?increment?"} {too many args}

eval_is {
 set a 1
 incr
 puts $a
} {wrong # args: should be "incr varName ?increment?"} {too few args}

eval_is {
  set a 1
  incr a a
} {expected integer but got "a"} {expected integer, got alpha}

# This test fails in tclsh8.5a5:
# https://sourceforge.net/tracker/?func=detail&atid=110894&aid=1602991&group_id=10894
eval_is {
  set a 1
  incr a 1.5
} {expected integer but got "1.5"} {expected integer, got float}

# as of 8.5, this autovivifies the variable
eval_is {
  catch {unset a}
  incr a
} 1 {no such variable}


# Uses the same parsing mechanism as
# [expr <octal>] - all the edge cases are tested there.
eval_is {
  set i 25
  incr i 000012345
  set i
} 5374 {octal offset}

eval_is {
  set x foo
  incr x
} {expected integer but got "foo"} {not an int}

eval_is {
  set x { 14 }
  incr x
  set x
} 15 {space padded int}

eval_is {
  set x 0xff
  incr x
  set x
} 256 {hex variable}

# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.