adlint 2.6.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -2,7 +2,7 @@
|
|
2
2
|
# iteration-statements.
|
3
3
|
#
|
4
4
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
5
|
-
# Copyright:: Copyright (C) 2010-
|
5
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
6
6
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
7
7
|
#
|
8
8
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
13
13
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
14
14
|
# / __ |/ /_/ / /___/ / /| / / /
|
15
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
15
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
16
16
|
#
|
17
17
|
# This file is part of AdLint.
|
18
18
|
#
|
@@ -33,45 +33,49 @@
|
|
33
33
|
require "spec_helper"
|
34
34
|
|
35
35
|
module AdLint
|
36
|
-
module
|
36
|
+
module Cc1
|
37
37
|
|
38
38
|
describe ControllingExpression do
|
39
|
-
|
39
|
+
include InterpreterMediator
|
40
|
+
|
41
|
+
before(:all) { @adlint = AdLint.new($default_traits) }
|
40
42
|
|
41
43
|
before(:each) do
|
44
|
+
@monitor = ProgressMonitor.new(nil, nil, false)
|
45
|
+
@logger = Logger.new(File.open(File::NULL, "w"))
|
42
46
|
@symbol_table = SymbolTable.new
|
43
|
-
@type_table
|
44
|
-
@interpreter
|
45
|
-
@int_i
|
46
|
-
@int_j
|
47
|
+
@type_table = TypeTable.new(@adlint.traits, @monitor, @logger)
|
48
|
+
@interpreter = Interpreter.new(@type_table)
|
49
|
+
@int_i = @interpreter.define_variable(int_i_def)
|
50
|
+
@int_j = @interpreter.define_variable(int_j_def)
|
47
51
|
end
|
48
52
|
|
49
53
|
context "`int i = ((> 0) && (< 10)) || (== 0)' and " +
|
50
54
|
"`int j = ((> 0) && (< 10)) || (== 0)'" do
|
51
55
|
before do
|
52
|
-
@int_i.narrow_value_domain!(Operator::GE,
|
53
|
-
@int_i.narrow_value_domain!(Operator::LT,
|
54
|
-
@int_j.narrow_value_domain!(Operator::GE,
|
55
|
-
@int_j.narrow_value_domain!(Operator::LT,
|
56
|
+
@int_i.narrow_value_domain!(Operator::GE, scalar_value_of(0))
|
57
|
+
@int_i.narrow_value_domain!(Operator::LT, scalar_value_of(10))
|
58
|
+
@int_j.narrow_value_domain!(Operator::GE, scalar_value_of(0))
|
59
|
+
@int_j.narrow_value_domain!(Operator::LT, scalar_value_of(10))
|
56
60
|
end
|
57
61
|
|
58
62
|
it "(i == j) makes that `i' should contain 0 and 9, " +
|
59
63
|
"and should not contain 10" do
|
60
|
-
expr = EqualityExpression.new(
|
64
|
+
expr = EqualityExpression.new(eq_op, i_spec, j_spec)
|
61
65
|
branched_eval(expr, NARROWING, FINAL) do
|
62
|
-
@int_i.value.may_be_equal_to?(
|
63
|
-
@int_i.value.may_be_equal_to?(
|
64
|
-
@int_i.value.may_be_equal_to?(
|
66
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(0)).should be_true
|
67
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(9)).should be_true
|
68
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(10)).should_not be_true
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
68
72
|
it "(i != j) makes that `i' should contain 0 and 9, " +
|
69
73
|
"and should not contain 10" do
|
70
|
-
expr = EqualityExpression.new(
|
74
|
+
expr = EqualityExpression.new(ne_op, i_spec, j_spec)
|
71
75
|
branched_eval(expr, NARROWING, FINAL) do
|
72
|
-
@int_i.value.may_be_equal_to?(
|
73
|
-
@int_i.value.may_be_equal_to?(
|
74
|
-
@int_i.value.may_be_equal_to?(
|
76
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(0)).should be_true
|
77
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(9)).should be_true
|
78
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(10)).should_not be_true
|
75
79
|
end
|
76
80
|
end
|
77
81
|
end
|
@@ -79,73 +83,71 @@ module C
|
|
79
83
|
context "`int i = ((> 0) && (< 10)) || (== 0)' and " +
|
80
84
|
"`int j = ((> 3) && (< 5)) || (== 3)'" do
|
81
85
|
before do
|
82
|
-
@int_i.narrow_value_domain!(Operator::GE,
|
83
|
-
@int_i.narrow_value_domain!(Operator::LT,
|
84
|
-
@int_j.narrow_value_domain!(Operator::GE,
|
85
|
-
@int_j.narrow_value_domain!(Operator::LT,
|
86
|
+
@int_i.narrow_value_domain!(Operator::GE, scalar_value_of(0))
|
87
|
+
@int_i.narrow_value_domain!(Operator::LT, scalar_value_of(10))
|
88
|
+
@int_j.narrow_value_domain!(Operator::GE, scalar_value_of(3))
|
89
|
+
@int_j.narrow_value_domain!(Operator::LT, scalar_value_of(5))
|
86
90
|
end
|
87
91
|
|
88
92
|
it "(i == j) makes that `i' should contain 3 and 4, " +
|
89
93
|
"and should not contain 0" do
|
90
|
-
expr = EqualityExpression.new(
|
94
|
+
expr = EqualityExpression.new(eq_op, i_spec, j_spec)
|
91
95
|
branched_eval(expr, NARROWING, FINAL) do
|
92
|
-
@int_i.value.may_be_equal_to?(
|
93
|
-
@int_i.value.may_be_equal_to?(
|
94
|
-
@int_i.value.may_be_equal_to?(
|
96
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(3)).should be_true
|
97
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(4)).should be_true
|
98
|
+
@int_i.value.may_be_equal_to?(scalar_value_of(0)).should_not be_true
|
95
99
|
end
|
96
100
|
end
|
97
101
|
end
|
98
102
|
|
99
|
-
include InterpreterMediator
|
100
|
-
|
101
103
|
private
|
102
|
-
def
|
104
|
+
def eq_op
|
103
105
|
Token.new("==", "==", nil_loc)
|
104
106
|
end
|
105
107
|
|
106
|
-
def
|
108
|
+
def ne_op
|
107
109
|
Token.new("!=", "!=", nil_loc)
|
108
110
|
end
|
109
111
|
|
110
|
-
def
|
111
|
-
|
112
|
+
def i_spec
|
113
|
+
obj_spec_of("i")
|
112
114
|
end
|
113
115
|
|
114
|
-
def
|
115
|
-
|
116
|
+
def j_spec
|
117
|
+
obj_spec_of("j")
|
116
118
|
end
|
117
119
|
|
118
|
-
def
|
119
|
-
ObjectSpecifier.new(
|
120
|
+
def obj_spec_of(name)
|
121
|
+
ObjectSpecifier.new(id_of(name))
|
120
122
|
end
|
121
123
|
|
122
|
-
def
|
123
|
-
uninitialized_int_vardef("i", @type_table.
|
124
|
+
def int_i_def
|
125
|
+
uninitialized_int_vardef("i", @type_table.int_t)
|
124
126
|
end
|
125
127
|
|
126
|
-
def
|
127
|
-
uninitialized_int_vardef("j", @type_table.
|
128
|
+
def int_j_def
|
129
|
+
uninitialized_int_vardef("j", @type_table.int_t)
|
128
130
|
end
|
129
131
|
|
130
132
|
def uninitialized_int_vardef(name, type)
|
131
|
-
|
132
|
-
ds.type_specifiers.push(
|
133
|
+
dcl_specs = DeclarationSpecifiers.new.tap { |ds|
|
134
|
+
ds.type_specifiers.push(int_t_spec)
|
133
135
|
}
|
134
|
-
decl = Declaration.new(
|
136
|
+
decl = Declaration.new(dcl_specs, [uninitialized_int_dcl(name)],
|
135
137
|
@symbol_table)
|
136
138
|
decl.items.each { |item| item.type = type }
|
137
139
|
decl.items.find { |item| item.kind_of?(VariableDefinition) }
|
138
140
|
end
|
139
141
|
|
140
|
-
def
|
141
|
-
InitDeclarator.new(IdentifierDeclarator.new(
|
142
|
+
def uninitialized_int_dcl(name)
|
143
|
+
InitDeclarator.new(IdentifierDeclarator.new(id_of(name)), nil)
|
142
144
|
end
|
143
145
|
|
144
|
-
def
|
146
|
+
def int_t_spec
|
145
147
|
StandardTypeSpecifier.new(Token.new(:INT, "int", Location.new))
|
146
148
|
end
|
147
149
|
|
148
|
-
def
|
150
|
+
def id_of(name)
|
149
151
|
Token.new(:IDENTIFIER, name, nil_loc)
|
150
152
|
end
|
151
153
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Unit specification of domain of values bound to variables.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
6
|
#
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -32,173 +32,177 @@
|
|
32
32
|
require "spec_helper"
|
33
33
|
|
34
34
|
module AdLint
|
35
|
-
module
|
35
|
+
module Cc1
|
36
36
|
|
37
37
|
describe ValueDomain do
|
38
|
+
include ArithmeticAccessor
|
39
|
+
|
40
|
+
before(:all) { @adlint = AdLint.new($default_traits) }
|
41
|
+
|
38
42
|
describe EqualToValueDomain do
|
39
43
|
context "(== -2147483648)" do
|
40
|
-
subject {
|
44
|
+
subject { value_domain_equal_to(-2147483648) }
|
41
45
|
|
42
46
|
it "should contain (== -2147483648)" do
|
43
|
-
subject.contain?(
|
47
|
+
subject.contain?(value_domain_equal_to(-2147483648)).should be_true
|
44
48
|
end
|
45
49
|
|
46
50
|
it "should not contain (== 2147483647)" do
|
47
|
-
subject.contain?(
|
51
|
+
subject.contain?(value_domain_equal_to(2147483647)).should be_false
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
55
|
context "(== 2147483647)" do
|
52
|
-
subject {
|
56
|
+
subject { value_domain_equal_to(2147483647) }
|
53
57
|
|
54
58
|
it "should not contain (== -2147483648)" do
|
55
|
-
subject.contain?(
|
59
|
+
subject.contain?(value_domain_equal_to(-2147483648)).should be_false
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
context "(== 2)" do
|
60
|
-
subject {
|
64
|
+
subject { value_domain_equal_to(2) }
|
61
65
|
|
62
66
|
it "* (== 3) should be (== 6)" do
|
63
|
-
rhs =
|
67
|
+
rhs = value_domain_equal_to(3)
|
64
68
|
(subject * rhs).to_s.should == "(== 6)"
|
65
69
|
end
|
66
70
|
|
67
71
|
it "* (== 0) should be (== 0)" do
|
68
|
-
rhs =
|
72
|
+
rhs = value_domain_equal_to(0)
|
69
73
|
(subject * rhs).to_s.should == "(== 0)"
|
70
74
|
end
|
71
75
|
|
72
76
|
it "* (== -3) should be (== -6)" do
|
73
|
-
rhs =
|
77
|
+
rhs = value_domain_equal_to(-3)
|
74
78
|
(subject * rhs).to_s.should == "(== -6)"
|
75
79
|
end
|
76
80
|
|
77
81
|
it "* (< 3) should be (< 6)" do
|
78
|
-
rhs =
|
82
|
+
rhs = value_domain_less_than(3)
|
79
83
|
(subject * rhs).to_s.should == "(< 6)"
|
80
84
|
end
|
81
85
|
|
82
86
|
it "* (< 0) should be (< 0)" do
|
83
|
-
rhs =
|
87
|
+
rhs = value_domain_less_than(0)
|
84
88
|
(subject * rhs).to_s.should == "(< 0)"
|
85
89
|
end
|
86
90
|
|
87
91
|
it "* (< -3) should be (< -6)" do
|
88
|
-
rhs =
|
92
|
+
rhs = value_domain_less_than(-3)
|
89
93
|
(subject * rhs).to_s.should == "(< -6)"
|
90
94
|
end
|
91
95
|
|
92
96
|
it "* (> 3) should be (> 6)" do
|
93
|
-
rhs =
|
97
|
+
rhs = value_domain_greater_than(3)
|
94
98
|
(subject * rhs).to_s.should == "(> 6)"
|
95
99
|
end
|
96
100
|
|
97
101
|
it "* (> 0) should be (> 0)" do
|
98
|
-
rhs =
|
102
|
+
rhs = value_domain_greater_than(0)
|
99
103
|
(subject * rhs).to_s.should == "(> 0)"
|
100
104
|
end
|
101
105
|
|
102
106
|
it "* (> -3) should be (> -6)" do
|
103
|
-
rhs =
|
107
|
+
rhs = value_domain_greater_than(-3)
|
104
108
|
(subject * rhs).to_s.should == "(> -6)"
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
108
112
|
context "(== 0)" do
|
109
|
-
subject {
|
113
|
+
subject { value_domain_equal_to(0) }
|
110
114
|
|
111
115
|
it "* (== 3) should be (== 0)" do
|
112
|
-
rhs =
|
116
|
+
rhs = value_domain_equal_to(3)
|
113
117
|
(subject * rhs).to_s.should == "(== 0)"
|
114
118
|
end
|
115
119
|
|
116
120
|
it "* (== 0) should be (== 0)" do
|
117
|
-
rhs =
|
121
|
+
rhs = value_domain_equal_to(0)
|
118
122
|
(subject * rhs).to_s.should == "(== 0)"
|
119
123
|
end
|
120
124
|
|
121
125
|
it "* (== -3) should be (== 0)" do
|
122
|
-
rhs =
|
126
|
+
rhs = value_domain_equal_to(-3)
|
123
127
|
(subject * rhs).to_s.should == "(== 0)"
|
124
128
|
end
|
125
129
|
|
126
130
|
it "* (< 3) should be (== 0)" do
|
127
|
-
rhs =
|
131
|
+
rhs = value_domain_less_than(3)
|
128
132
|
(subject * rhs).to_s.should == "(== 0)"
|
129
133
|
end
|
130
134
|
|
131
135
|
it "* (< 0) should be (== 0)" do
|
132
|
-
rhs =
|
136
|
+
rhs = value_domain_less_than(0)
|
133
137
|
(subject * rhs).to_s.should == "(== 0)"
|
134
138
|
end
|
135
139
|
|
136
140
|
it "* (< -3) should be (== 0)" do
|
137
|
-
rhs =
|
141
|
+
rhs = value_domain_less_than(-3)
|
138
142
|
(subject * rhs).to_s.should == "(== 0)"
|
139
143
|
end
|
140
144
|
|
141
145
|
it "* (> 3) should be (== 0)" do
|
142
|
-
rhs =
|
146
|
+
rhs = value_domain_greater_than(3)
|
143
147
|
(subject * rhs).to_s.should == "(== 0)"
|
144
148
|
end
|
145
149
|
|
146
150
|
it "* (> 0) should be (== 0)" do
|
147
|
-
rhs =
|
151
|
+
rhs = value_domain_greater_than(0)
|
148
152
|
(subject * rhs).to_s.should == "(== 0)"
|
149
153
|
end
|
150
154
|
|
151
155
|
it "* (> -3) should be (== 0)" do
|
152
|
-
rhs =
|
156
|
+
rhs = value_domain_greater_than(-3)
|
153
157
|
(subject * rhs).to_s.should == "(== 0)"
|
154
158
|
end
|
155
159
|
end
|
156
160
|
|
157
161
|
context "(== -2)" do
|
158
|
-
subject {
|
162
|
+
subject { value_domain_equal_to(-2) }
|
159
163
|
|
160
164
|
it "* (== 3) should be (== -6)" do
|
161
|
-
rhs =
|
165
|
+
rhs = value_domain_equal_to(3)
|
162
166
|
(subject * rhs).to_s.should == "(== -6)"
|
163
167
|
end
|
164
168
|
|
165
169
|
it "* (== 0) should be (== 0)" do
|
166
|
-
rhs =
|
170
|
+
rhs = value_domain_equal_to(0)
|
167
171
|
(subject * rhs).to_s.should == "(== 0)"
|
168
172
|
end
|
169
173
|
|
170
174
|
it "* (== -3) should be (== 6)" do
|
171
|
-
rhs =
|
175
|
+
rhs = value_domain_equal_to(-3)
|
172
176
|
(subject * rhs).to_s.should == "(== 6)"
|
173
177
|
end
|
174
178
|
|
175
179
|
it "* (< 3) should be (> -6)" do
|
176
|
-
rhs =
|
180
|
+
rhs = value_domain_less_than(3)
|
177
181
|
(subject * rhs).to_s.should == "(> -6)"
|
178
182
|
end
|
179
183
|
|
180
184
|
it "* (< 0) should be (> 0)" do
|
181
|
-
rhs =
|
185
|
+
rhs = value_domain_less_than(0)
|
182
186
|
(subject * rhs).to_s.should == "(> 0)"
|
183
187
|
end
|
184
188
|
|
185
189
|
it "* (< -3) should be (> 6)" do
|
186
|
-
rhs =
|
190
|
+
rhs = value_domain_less_than(-3)
|
187
191
|
(subject * rhs).to_s.should == "(> 6)"
|
188
192
|
end
|
189
193
|
|
190
194
|
it "* (> 3) should be (< -6)" do
|
191
|
-
rhs =
|
195
|
+
rhs = value_domain_greater_than(3)
|
192
196
|
(subject * rhs).to_s.should == "(< -6)"
|
193
197
|
end
|
194
198
|
|
195
199
|
it "* (> 0) should be (< 0)" do
|
196
|
-
rhs =
|
200
|
+
rhs = value_domain_greater_than(0)
|
197
201
|
(subject * rhs).to_s.should == "(< 0)"
|
198
202
|
end
|
199
203
|
|
200
204
|
it "* (> -3) should be (< 6)" do
|
201
|
-
rhs =
|
205
|
+
rhs = value_domain_greater_than(-3)
|
202
206
|
(subject * rhs).to_s.should == "(< 6)"
|
203
207
|
end
|
204
208
|
end
|
@@ -206,157 +210,157 @@ module C
|
|
206
210
|
|
207
211
|
describe LessThanValueDomain do
|
208
212
|
context "(< 128)" do
|
209
|
-
subject {
|
213
|
+
subject { value_domain_less_than(128) }
|
210
214
|
|
211
215
|
it "< (== 127) should be (== Unlimited)" do
|
212
|
-
rhs =
|
216
|
+
rhs = value_domain_equal_to(127)
|
213
217
|
(subject < rhs).to_s.should == "(== Unlimited)"
|
214
218
|
end
|
215
219
|
end
|
216
220
|
|
217
221
|
context "(< 2)" do
|
218
|
-
subject {
|
222
|
+
subject { value_domain_less_than(2) }
|
219
223
|
|
220
224
|
it "* (== 3) should be (< 6)" do
|
221
|
-
rhs =
|
225
|
+
rhs = value_domain_equal_to(3)
|
222
226
|
(subject * rhs).to_s.should == "(< 6)"
|
223
227
|
end
|
224
228
|
|
225
229
|
it "* (== 0) should be (== 0)" do
|
226
|
-
rhs =
|
230
|
+
rhs = value_domain_equal_to(0)
|
227
231
|
(subject * rhs).to_s.should == "(== 0)"
|
228
232
|
end
|
229
233
|
|
230
234
|
it "* (== -3) should be (> -6)" do
|
231
|
-
rhs =
|
235
|
+
rhs = value_domain_equal_to(-3)
|
232
236
|
(subject * rhs).to_s.should == "(> -6)"
|
233
237
|
end
|
234
238
|
|
235
239
|
it "* (< 3) should be (== Unlimited)" do
|
236
|
-
rhs =
|
240
|
+
rhs = value_domain_less_than(3)
|
237
241
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
238
242
|
end
|
239
243
|
|
240
244
|
it "* (< 0) should be (== Unlimited)" do
|
241
|
-
rhs =
|
245
|
+
rhs = value_domain_less_than(0)
|
242
246
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
243
247
|
end
|
244
248
|
|
245
249
|
it "* (< -3) should be (== Unlimited)" do
|
246
|
-
rhs =
|
250
|
+
rhs = value_domain_less_than(-3)
|
247
251
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
248
252
|
end
|
249
253
|
|
250
254
|
it "* (> 3) should be (== Unlimited)" do
|
251
|
-
rhs =
|
255
|
+
rhs = value_domain_greater_than(3)
|
252
256
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
253
257
|
end
|
254
258
|
|
255
259
|
it "* (> 0) should be (== Unlimited)" do
|
256
|
-
rhs =
|
260
|
+
rhs = value_domain_greater_than(0)
|
257
261
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
258
262
|
end
|
259
263
|
|
260
264
|
it "* (> -3) should be (== Unlimited)" do
|
261
|
-
rhs =
|
265
|
+
rhs = value_domain_greater_than(-3)
|
262
266
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
263
267
|
end
|
264
268
|
end
|
265
269
|
|
266
270
|
context "(< 0)" do
|
267
|
-
subject {
|
271
|
+
subject { value_domain_less_than(0) }
|
268
272
|
|
269
273
|
it "* (== 3) should be (< 0)" do
|
270
|
-
rhs =
|
274
|
+
rhs = value_domain_equal_to(3)
|
271
275
|
(subject * rhs).to_s.should == "(< 0)"
|
272
276
|
end
|
273
277
|
|
274
278
|
it "* (== 0) should be (== 0)" do
|
275
|
-
rhs =
|
279
|
+
rhs = value_domain_equal_to(0)
|
276
280
|
(subject * rhs).to_s.should == "(== 0)"
|
277
281
|
end
|
278
282
|
|
279
283
|
it "* (== -3) should be (> 0)" do
|
280
|
-
rhs =
|
284
|
+
rhs = value_domain_equal_to(-3)
|
281
285
|
(subject * rhs).to_s.should == "(> 0)"
|
282
286
|
end
|
283
287
|
|
284
288
|
it "* (< 3) should be (== Unlimited)" do
|
285
|
-
rhs =
|
289
|
+
rhs = value_domain_less_than(3)
|
286
290
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
287
291
|
end
|
288
292
|
|
289
293
|
it "* (< 0) should be (> 0)" do
|
290
|
-
rhs =
|
294
|
+
rhs = value_domain_less_than(0)
|
291
295
|
(subject * rhs).to_s.should == "(> 0)"
|
292
296
|
end
|
293
297
|
|
294
298
|
it "* (< -3) should be (> 0)" do
|
295
|
-
rhs =
|
299
|
+
rhs = value_domain_less_than(-3)
|
296
300
|
(subject * rhs).to_s.should == "(> 0)"
|
297
301
|
end
|
298
302
|
|
299
303
|
it "* (> 3) should be (< 0)" do
|
300
|
-
rhs =
|
304
|
+
rhs = value_domain_greater_than(3)
|
301
305
|
(subject * rhs).to_s.should == "(< 0)"
|
302
306
|
end
|
303
307
|
|
304
308
|
it "* (> 0) should be (< 0)" do
|
305
|
-
rhs =
|
309
|
+
rhs = value_domain_greater_than(0)
|
306
310
|
(subject * rhs).to_s.should == "(< 0)"
|
307
311
|
end
|
308
312
|
|
309
313
|
it "* (> -3) should be (== Unlimited)" do
|
310
|
-
rhs =
|
314
|
+
rhs = value_domain_greater_than(-3)
|
311
315
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
312
316
|
end
|
313
317
|
end
|
314
318
|
|
315
319
|
context "(< -2)" do
|
316
|
-
subject {
|
320
|
+
subject { value_domain_less_than(-2) }
|
317
321
|
|
318
322
|
it "* (== 3) should be (< -6)" do
|
319
|
-
rhs =
|
323
|
+
rhs = value_domain_equal_to(3)
|
320
324
|
(subject * rhs).to_s.should == "(< -6)"
|
321
325
|
end
|
322
326
|
|
323
327
|
it "* (== 0) should be (== 0)" do
|
324
|
-
rhs =
|
328
|
+
rhs = value_domain_equal_to(0)
|
325
329
|
(subject * rhs).to_s.should == "(== 0)"
|
326
330
|
end
|
327
331
|
|
328
332
|
it "* (== -3) should be (> 6)" do
|
329
|
-
rhs =
|
333
|
+
rhs = value_domain_equal_to(-3)
|
330
334
|
(subject * rhs).to_s.should == "(> 6)"
|
331
335
|
end
|
332
336
|
|
333
337
|
it "* (< 3) should be (== Unlimited)" do
|
334
|
-
rhs =
|
338
|
+
rhs = value_domain_less_than(3)
|
335
339
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
336
340
|
end
|
337
341
|
|
338
342
|
it "* (< 0) should be (> 0)" do
|
339
|
-
rhs =
|
343
|
+
rhs = value_domain_less_than(0)
|
340
344
|
(subject * rhs).to_s.should == "(> 0)"
|
341
345
|
end
|
342
346
|
|
343
347
|
it "* (< -3) should be (> 6)" do
|
344
|
-
rhs =
|
348
|
+
rhs = value_domain_less_than(-3)
|
345
349
|
(subject * rhs).to_s.should == "(> 6)"
|
346
350
|
end
|
347
351
|
|
348
352
|
it "* (> 3) should be (< -6)" do
|
349
|
-
rhs =
|
353
|
+
rhs = value_domain_greater_than(3)
|
350
354
|
(subject * rhs).to_s.should == "(< -6)"
|
351
355
|
end
|
352
356
|
|
353
357
|
it "* (> 0) should be (< 0)" do
|
354
|
-
rhs =
|
358
|
+
rhs = value_domain_greater_than(0)
|
355
359
|
(subject * rhs).to_s.should == "(< 0)"
|
356
360
|
end
|
357
361
|
|
358
362
|
it "* (> -3) should be (== Unlimited)" do
|
359
|
-
rhs =
|
363
|
+
rhs = value_domain_greater_than(-3)
|
360
364
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
361
365
|
end
|
362
366
|
end
|
@@ -364,157 +368,157 @@ module C
|
|
364
368
|
|
365
369
|
describe GreaterThanValueDomain do
|
366
370
|
context "(> -129)" do
|
367
|
-
subject {
|
371
|
+
subject { value_domain_greater_than(-129) }
|
368
372
|
|
369
373
|
it "< (== 127) should be (== Unlimited)" do
|
370
|
-
rhs =
|
374
|
+
rhs = value_domain_equal_to(127)
|
371
375
|
(subject < rhs).to_s.should == "(== Unlimited)"
|
372
376
|
end
|
373
377
|
end
|
374
378
|
|
375
379
|
context "(> 2)" do
|
376
|
-
subject {
|
380
|
+
subject { value_domain_greater_than(2) }
|
377
381
|
|
378
382
|
it "* (== 3) should be (> 6)" do
|
379
|
-
rhs =
|
383
|
+
rhs = value_domain_equal_to(3)
|
380
384
|
(subject * rhs).to_s.should == "(> 6)"
|
381
385
|
end
|
382
386
|
|
383
387
|
it "* (== 0) should be (== 0)" do
|
384
|
-
rhs =
|
388
|
+
rhs = value_domain_equal_to(0)
|
385
389
|
(subject * rhs).to_s.should == "(== 0)"
|
386
390
|
end
|
387
391
|
|
388
392
|
it "* (== -3) should be (< -6)" do
|
389
|
-
rhs =
|
393
|
+
rhs = value_domain_equal_to(-3)
|
390
394
|
(subject * rhs).to_s.should == "(< -6)"
|
391
395
|
end
|
392
396
|
|
393
397
|
it "* (< 3) should be (== Unlimited)" do
|
394
|
-
rhs =
|
398
|
+
rhs = value_domain_less_than(3)
|
395
399
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
396
400
|
end
|
397
401
|
|
398
402
|
it "* (< 0) should be (< 0)" do
|
399
|
-
rhs =
|
403
|
+
rhs = value_domain_less_than(0)
|
400
404
|
(subject * rhs).to_s.should == "(< 0)"
|
401
405
|
end
|
402
406
|
|
403
407
|
it "* (< -3) should be (< -6)" do
|
404
|
-
rhs =
|
408
|
+
rhs = value_domain_less_than(-3)
|
405
409
|
(subject * rhs).to_s.should == "(< -6)"
|
406
410
|
end
|
407
411
|
|
408
412
|
it "* (> 3) should be (> 6)" do
|
409
|
-
rhs =
|
413
|
+
rhs = value_domain_greater_than(3)
|
410
414
|
(subject * rhs).to_s.should == "(> 6)"
|
411
415
|
end
|
412
416
|
|
413
417
|
it "* (> 0) should be (> 0)" do
|
414
|
-
rhs =
|
418
|
+
rhs = value_domain_greater_than(0)
|
415
419
|
(subject * rhs).to_s.should == "(> 0)"
|
416
420
|
end
|
417
421
|
|
418
422
|
it "* (> -3) should be (== Unlimited)" do
|
419
|
-
rhs =
|
423
|
+
rhs = value_domain_greater_than(-3)
|
420
424
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
421
425
|
end
|
422
426
|
end
|
423
427
|
|
424
428
|
context "(> 0)" do
|
425
|
-
subject {
|
429
|
+
subject { value_domain_greater_than(0) }
|
426
430
|
|
427
431
|
it "* (== 3) should be (> 0)" do
|
428
|
-
rhs =
|
432
|
+
rhs = value_domain_equal_to(3)
|
429
433
|
(subject * rhs).to_s.should == "(> 0)"
|
430
434
|
end
|
431
435
|
|
432
436
|
it "* (== 0) should be (== 0)" do
|
433
|
-
rhs =
|
437
|
+
rhs = value_domain_equal_to(0)
|
434
438
|
(subject * rhs).to_s.should == "(== 0)"
|
435
439
|
end
|
436
440
|
|
437
441
|
it "* (== -3) should be (< 0)" do
|
438
|
-
rhs =
|
442
|
+
rhs = value_domain_equal_to(-3)
|
439
443
|
(subject * rhs).to_s.should == "(< 0)"
|
440
444
|
end
|
441
445
|
|
442
446
|
it "* (< 3) should be (== Unlimited)" do
|
443
|
-
rhs =
|
447
|
+
rhs = value_domain_less_than(3)
|
444
448
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
445
449
|
end
|
446
450
|
|
447
451
|
it "* (< 0) should be (< 0)" do
|
448
|
-
rhs =
|
452
|
+
rhs = value_domain_less_than(0)
|
449
453
|
(subject * rhs).to_s.should == "(< 0)"
|
450
454
|
end
|
451
455
|
|
452
456
|
it "* (< -3) should be (< 0)" do
|
453
|
-
rhs =
|
457
|
+
rhs = value_domain_less_than(-3)
|
454
458
|
(subject * rhs).to_s.should == "(< 0)"
|
455
459
|
end
|
456
460
|
|
457
461
|
it "* (> 3) should be (> 0)" do
|
458
|
-
rhs =
|
462
|
+
rhs = value_domain_greater_than(3)
|
459
463
|
(subject * rhs).to_s.should == "(> 0)"
|
460
464
|
end
|
461
465
|
|
462
466
|
it "* (> 0) should be (> 0)" do
|
463
|
-
rhs =
|
467
|
+
rhs = value_domain_greater_than(0)
|
464
468
|
(subject * rhs).to_s.should == "(> 0)"
|
465
469
|
end
|
466
470
|
|
467
471
|
it "* (> -3) should be (== Unlimited)" do
|
468
|
-
rhs =
|
472
|
+
rhs = value_domain_greater_than(-3)
|
469
473
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
470
474
|
end
|
471
475
|
end
|
472
476
|
|
473
477
|
context "(> -2)" do
|
474
|
-
subject {
|
478
|
+
subject { value_domain_greater_than(-2) }
|
475
479
|
|
476
480
|
it "* (== 3) should be (> -6)" do
|
477
|
-
rhs =
|
481
|
+
rhs = value_domain_equal_to(3)
|
478
482
|
(subject * rhs).to_s.should == "(> -6)"
|
479
483
|
end
|
480
484
|
|
481
485
|
it "* (== 0) should be (== 0)" do
|
482
|
-
rhs =
|
486
|
+
rhs = value_domain_equal_to(0)
|
483
487
|
(subject * rhs).to_s.should == "(== 0)"
|
484
488
|
end
|
485
489
|
|
486
490
|
it "* (== -3) should be (< 6)" do
|
487
|
-
rhs =
|
491
|
+
rhs = value_domain_equal_to(-3)
|
488
492
|
(subject * rhs).to_s.should == "(< 6)"
|
489
493
|
end
|
490
494
|
|
491
495
|
it "* (< 3) should be (== Unlimited)" do
|
492
|
-
rhs =
|
496
|
+
rhs = value_domain_less_than(3)
|
493
497
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
494
498
|
end
|
495
499
|
|
496
500
|
it "* (< 0) should be (== Unlimited)" do
|
497
|
-
rhs =
|
501
|
+
rhs = value_domain_less_than(0)
|
498
502
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
499
503
|
end
|
500
504
|
|
501
505
|
it "* (< -3) should be (== Unlimited)" do
|
502
|
-
rhs =
|
506
|
+
rhs = value_domain_less_than(-3)
|
503
507
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
504
508
|
end
|
505
509
|
|
506
510
|
it "* (> 3) should be (== Unlimited)" do
|
507
|
-
rhs =
|
511
|
+
rhs = value_domain_greater_than(3)
|
508
512
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
509
513
|
end
|
510
514
|
|
511
515
|
it "* (> 0) should be (== Unlimited)" do
|
512
|
-
rhs =
|
516
|
+
rhs = value_domain_greater_than(0)
|
513
517
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
514
518
|
end
|
515
519
|
|
516
520
|
it "* (> -3) should be (== Unlimited)" do
|
517
|
-
rhs =
|
521
|
+
rhs = value_domain_greater_than(-3)
|
518
522
|
(subject * rhs).to_s.should == "(== Unlimited)"
|
519
523
|
end
|
520
524
|
end
|
@@ -523,86 +527,86 @@ module C
|
|
523
527
|
describe CompositeValueDomain do
|
524
528
|
context "(== (((< 10) || (== 10)) && ((== -10) || (> -10))))" do
|
525
529
|
subject do
|
526
|
-
tmp =
|
527
|
-
tmp.intersection(
|
530
|
+
tmp = value_domain_greater_than_or_equal_to(-10)
|
531
|
+
tmp.intersection(value_domain_less_than_or_equal_to(10))
|
528
532
|
end
|
529
533
|
|
530
534
|
it "should contain ((== -5) || (== 5))" do
|
531
|
-
rhs =
|
535
|
+
rhs = value_domain_equal_to(-5).union(value_domain_equal_to(5))
|
532
536
|
subject.contain?(rhs).should be_true
|
533
537
|
end
|
534
538
|
end
|
535
539
|
|
536
540
|
context "((== -5) || (== 5))" do
|
537
|
-
subject {
|
541
|
+
subject { value_domain_equal_to(-5).union(value_domain_equal_to(5)) }
|
538
542
|
|
539
543
|
it "should not contain " +
|
540
544
|
"(((< 10) || (== 10)) && ((== -10) || (> -10)))" do
|
541
|
-
rhs =
|
542
|
-
rhs = rhs.intersection(
|
545
|
+
rhs = value_domain_greater_than_or_equal_to(-10)
|
546
|
+
rhs = rhs.intersection(value_domain_less_than_or_equal_to(10))
|
543
547
|
subject.contain?(rhs).should be_false
|
544
548
|
end
|
545
549
|
|
546
550
|
it "should be contained by " +
|
547
551
|
"(((< 10) || (== 10)) && ((== -10) || (> -10)))" do
|
548
|
-
lhs =
|
549
|
-
lhs = lhs.intersection(
|
552
|
+
lhs = value_domain_greater_than_or_equal_to(-10)
|
553
|
+
lhs = lhs.intersection(value_domain_less_than_or_equal_to(10))
|
550
554
|
lhs.contain?(subject).should be_true
|
551
555
|
end
|
552
556
|
|
553
557
|
it "intersection with (< 0) should be equal to (== -5)" do
|
554
|
-
rhs =
|
558
|
+
rhs = value_domain_less_than(0)
|
555
559
|
subject.intersection(rhs).to_s.should == "(== -5)"
|
556
560
|
end
|
557
561
|
|
558
562
|
it "intersection with (> 0) should be equal to (== 5)" do
|
559
|
-
rhs =
|
563
|
+
rhs = value_domain_greater_than(0)
|
560
564
|
subject.intersection(rhs).to_s.should == "(== 5)"
|
561
565
|
end
|
562
566
|
|
563
567
|
it "intersection with ((== -10) || (> -10)) " +
|
564
568
|
"should be equal to the subject domain" do
|
565
|
-
rhs =
|
569
|
+
rhs = value_domain_greater_than_or_equal_to(-10)
|
566
570
|
subject.intersection(rhs).should == subject
|
567
571
|
end
|
568
572
|
|
569
573
|
it "intersection with ((== 10) || (< 10)) " +
|
570
574
|
"should be equal to the subject domain" do
|
571
|
-
rhs =
|
575
|
+
rhs = value_domain_less_than_or_equal_to(10)
|
572
576
|
subject.intersection(rhs).should == subject
|
573
577
|
end
|
574
578
|
|
575
579
|
it "should not contain (((< 0) && (> -10)) || (== -10))" do
|
576
|
-
rhs =
|
577
|
-
rhs = rhs.intersection(
|
578
|
-
rhs = rhs.intersection(
|
580
|
+
rhs = value_domain_greater_than_or_equal_to(-10)
|
581
|
+
rhs = rhs.intersection(value_domain_less_than_or_equal_to(10))
|
582
|
+
rhs = rhs.intersection(value_domain_less_than(0))
|
579
583
|
subject.contain?(rhs).should be_false
|
580
584
|
end
|
581
585
|
end
|
582
586
|
|
583
587
|
context "(((< 0) && (> -10)) || (== -10))" do
|
584
588
|
subject do
|
585
|
-
tmp =
|
586
|
-
tmp = tmp.intersection(
|
587
|
-
tmp.intersection(
|
589
|
+
tmp = value_domain_greater_than_or_equal_to(-10)
|
590
|
+
tmp = tmp.intersection(value_domain_less_than_or_equal_to(10))
|
591
|
+
tmp.intersection(value_domain_less_than(0))
|
588
592
|
end
|
589
593
|
|
590
594
|
it "should not contain ((== -5) || (== 5))" do
|
591
|
-
rhs =
|
595
|
+
rhs = value_domain_equal_to(-5).union(value_domain_equal_to(5))
|
592
596
|
subject.contain?(rhs).should be_false
|
593
597
|
end
|
594
598
|
end
|
595
599
|
|
596
600
|
context "(((< 0) && (> -2147483647)) || (== 0))" do
|
597
601
|
subject do
|
598
|
-
tmp =
|
599
|
-
tmp.intersection(
|
602
|
+
tmp = value_domain_less_than_or_equal_to(0)
|
603
|
+
tmp.intersection(value_domain_greater_than_or_equal_to(-2147483647))
|
600
604
|
end
|
601
605
|
|
602
606
|
it "union with ((== -2147483647) || (== 0)) should be " +
|
603
607
|
"((((< 0) && (> -2147483647)) || (== -2147483647)) || (== 0))" do
|
604
|
-
rhs =
|
605
|
-
rhs = rhs.union(
|
608
|
+
rhs = value_domain_equal_to(-2147483647)
|
609
|
+
rhs = rhs.union(value_domain_equal_to(0))
|
606
610
|
subject.union(rhs).to_s.should ==
|
607
611
|
"((((< 0) && (> -2147483647)) || (== -2147483647)) || (== 0))"
|
608
612
|
end
|
@@ -610,29 +614,29 @@ module C
|
|
610
614
|
|
611
615
|
context "((== -2147483647) || (== 0))" do
|
612
616
|
subject do
|
613
|
-
|
617
|
+
value_domain_equal_to(-2147483647).union(value_domain_equal_to(0))
|
614
618
|
end
|
615
619
|
|
616
620
|
it "should contain ((== -2147483647) || (== 0))" do
|
617
|
-
rhs =
|
618
|
-
rhs = rhs.union(
|
621
|
+
rhs = value_domain_equal_to(-2147483647)
|
622
|
+
rhs = rhs.union(value_domain_equal_to(0))
|
619
623
|
subject.contain?(rhs).should be_true
|
620
624
|
end
|
621
625
|
|
622
626
|
it "should contain (== -2147483647)" do
|
623
|
-
subject.contain?(
|
627
|
+
subject.contain?(value_domain_equal_to(-2147483647)).should be_true
|
624
628
|
end
|
625
629
|
|
626
630
|
it "should contain (== 0)" do
|
627
|
-
subject.contain?(
|
631
|
+
subject.contain?(value_domain_equal_to(0)).should be_true
|
628
632
|
end
|
629
633
|
end
|
630
634
|
|
631
635
|
context "(((< 2147483647) && (> -2147483648)) || (== 2147483647))" do
|
632
636
|
subject do
|
633
|
-
tmp =
|
634
|
-
tmp = tmp.intersection(
|
635
|
-
tmp.union(
|
637
|
+
tmp = value_domain_greater_than(-2147483648)
|
638
|
+
tmp = tmp.intersection(value_domain_less_than(2147483647))
|
639
|
+
tmp.union(value_domain_equal_to(2147483647))
|
636
640
|
end
|
637
641
|
|
638
642
|
it "cloned should be " +
|
@@ -656,15 +660,15 @@ module C
|
|
656
660
|
|
657
661
|
context "(((< 2147483647) && (> 1)) || (== 1))" do
|
658
662
|
subject do
|
659
|
-
tmp =
|
660
|
-
tmp = tmp.intersection(
|
661
|
-
tmp.union(
|
663
|
+
tmp = value_domain_greater_than(1)
|
664
|
+
tmp = tmp.intersection(value_domain_less_than(2147483647))
|
665
|
+
tmp.union(value_domain_equal_to(1))
|
662
666
|
end
|
663
667
|
|
664
668
|
it "union with ((== 1) || (== 2147483647)) should be " +
|
665
669
|
"(((< 2147483647) && (> 1)) || ((== 1) || (== 2147483647)))" do
|
666
|
-
rhs =
|
667
|
-
rhs = rhs.union(
|
670
|
+
rhs = value_domain_equal_to(1)
|
671
|
+
rhs = rhs.union(value_domain_equal_to(2147483647))
|
668
672
|
subject.union(rhs).to_s.should ==
|
669
673
|
"(((< 2147483647) && (> 1)) || ((== 1) || (== 2147483647)))"
|
670
674
|
end
|
@@ -672,21 +676,23 @@ module C
|
|
672
676
|
|
673
677
|
context "(((< 429) && (> 0)) || (== 429))" do
|
674
678
|
subject do
|
675
|
-
tmp =
|
676
|
-
tmp = tmp.intersection(
|
677
|
-
tmp.union(
|
679
|
+
tmp = value_domain_greater_than(0)
|
680
|
+
tmp = tmp.intersection(value_domain_less_than(429))
|
681
|
+
tmp.union(value_domain_equal_to(429))
|
678
682
|
end
|
679
683
|
|
680
684
|
it "intersection with (== 0) should be (== Nil)" do
|
681
|
-
subject.intersection(
|
685
|
+
subject.intersection(value_domain_equal_to(0)).to_s.should ==
|
682
686
|
"(== Nil)"
|
683
687
|
end
|
684
688
|
end
|
685
689
|
|
686
690
|
context "(((< 10) || (== 10)) && ((== 0) || (> 0)))" do
|
687
691
|
subject do
|
688
|
-
ValueDomain.of_intersection(
|
689
|
-
|
692
|
+
ValueDomain.of_intersection(
|
693
|
+
value_domain_greater_than_or_equal_to(0),
|
694
|
+
value_domain_less_than_or_equal_to(10)
|
695
|
+
)
|
690
696
|
end
|
691
697
|
|
692
698
|
it "+ (((< 10) || (== 10)) && ((== 0) || (> 0))) " +
|
@@ -698,53 +704,53 @@ module C
|
|
698
704
|
|
699
705
|
context "((((< 10) && (> -10)) || (== 10)) || (== -10))" do
|
700
706
|
subject do
|
701
|
-
tmp =
|
702
|
-
tmp.intersection(
|
707
|
+
tmp = value_domain_greater_than_or_equal_to(-10)
|
708
|
+
tmp.intersection(value_domain_less_than_or_equal_to(10))
|
703
709
|
end
|
704
710
|
|
705
711
|
it "should intersect with (== 0)" do
|
706
|
-
subject.intersect?(
|
712
|
+
subject.intersect?(value_domain_equal_to(0)).should be_true
|
707
713
|
end
|
708
714
|
|
709
715
|
it "< (== 0) should be (== Unlimited)" do
|
710
|
-
(subject <
|
716
|
+
(subject < value_domain_equal_to(0)).to_s.should == "(== Unlimited)"
|
711
717
|
end
|
712
718
|
|
713
719
|
it "> (== 0) should be (== Unlimited)" do
|
714
|
-
(subject >
|
720
|
+
(subject > value_domain_equal_to(0)).to_s.should == "(== Unlimited)"
|
715
721
|
end
|
716
722
|
|
717
723
|
it "== (== 0) should be (== Unlimited)" do
|
718
|
-
(subject ==
|
724
|
+
(subject == value_domain_equal_to(0)).to_s.should == "(== Unlimited)"
|
719
725
|
end
|
720
726
|
|
721
727
|
it "!= (== 0) should be (== Unlimited)" do
|
722
|
-
(subject !=
|
728
|
+
(subject != value_domain_equal_to(0)).to_s.should == "(== Unlimited)"
|
723
729
|
end
|
724
730
|
|
725
731
|
it "< (== 20) should be ((< 0) || (> 0))" do
|
726
|
-
(subject <
|
732
|
+
(subject < value_domain_equal_to(20)).to_s.should ==
|
727
733
|
"((< 0) || (> 0))"
|
728
734
|
end
|
729
735
|
|
730
736
|
it "> (== 20) should be (== 0)" do
|
731
|
-
(subject >
|
737
|
+
(subject > value_domain_equal_to(20)).to_s.should == "(== 0)"
|
732
738
|
end
|
733
739
|
end
|
734
740
|
|
735
741
|
context "(((< 11) && (> 1)) || (== 11))" do
|
736
742
|
subject do
|
737
|
-
tmp =
|
738
|
-
tmp = tmp.intersection(
|
739
|
-
tmp.union(
|
743
|
+
tmp = value_domain_greater_than(1)
|
744
|
+
tmp = tmp.intersection(value_domain_less_than(11))
|
745
|
+
tmp.union(value_domain_equal_to(11))
|
740
746
|
end
|
741
747
|
|
742
748
|
it "narrowed by == ((((< 10) && (> 0)) || (== 10)) || (== 0)) " +
|
743
749
|
"should be (((< 10) && (> 1)) || (== 10))" do
|
744
|
-
rhs =
|
745
|
-
rhs = rhs.intersection(
|
746
|
-
rhs = rhs.union(
|
747
|
-
rhs = rhs.union(
|
750
|
+
rhs = value_domain_greater_than(0)
|
751
|
+
rhs = rhs.intersection(value_domain_less_than(10))
|
752
|
+
rhs = rhs.union(value_domain_equal_to(0))
|
753
|
+
rhs = rhs.union(value_domain_equal_to(10))
|
748
754
|
subject.narrow(Operator::EQ, rhs).to_s.should ==
|
749
755
|
"(((< 10) && (> 1)) || (== 10))"
|
750
756
|
end
|
@@ -752,30 +758,30 @@ module C
|
|
752
758
|
|
753
759
|
context "((< 128) && (> -129))" do
|
754
760
|
subject do
|
755
|
-
tmp =
|
756
|
-
tmp.intersection(
|
761
|
+
tmp = value_domain_greater_than(-129)
|
762
|
+
tmp.intersection(value_domain_less_than(128))
|
757
763
|
end
|
758
764
|
|
759
765
|
it "should intersect with (== -128)" do
|
760
|
-
subject.intersect?(
|
766
|
+
subject.intersect?(value_domain_equal_to(-128)).should be_true
|
761
767
|
end
|
762
768
|
|
763
769
|
it "should intersect with (== 127)" do
|
764
|
-
subject.intersect?(
|
770
|
+
subject.intersect?(value_domain_equal_to(127)).should be_true
|
765
771
|
end
|
766
772
|
end
|
767
773
|
|
768
774
|
context "((((< 2147483647) && (> -2147483648)) || " +
|
769
775
|
"(== 2147483647)) || (== -2147483648))" do
|
770
776
|
subject do
|
771
|
-
tmp =
|
772
|
-
tmp.intersection(
|
777
|
+
tmp = value_domain_greater_than_or_equal_to(-2147483648)
|
778
|
+
tmp.intersection(value_domain_less_than_or_equal_to(2147483647))
|
773
779
|
end
|
774
780
|
|
775
781
|
it "narrowed by != (== 1) should be " +
|
776
782
|
"(((((< 1) && (> -2147483648)) || ((< 2147483647) && (> 1))) || " +
|
777
783
|
"(== 2147483647)) || (== -2147483648))" do
|
778
|
-
subject.narrow(Operator::NE,
|
784
|
+
subject.narrow(Operator::NE, value_domain_equal_to(1)).to_s.should ==
|
779
785
|
"(((((< 1) && (> -2147483648)) || ((< 2147483647) && (> 1))) || " +
|
780
786
|
"(== 2147483647)) || (== -2147483648))"
|
781
787
|
end
|
@@ -783,8 +789,8 @@ module C
|
|
783
789
|
|
784
790
|
context "(((< 10) && (> 0)) || (== 0))" do
|
785
791
|
subject do
|
786
|
-
tmp =
|
787
|
-
tmp.intersection(
|
792
|
+
tmp = value_domain_greater_than_or_equal_to(0)
|
793
|
+
tmp.intersection(value_domain_less_than(10))
|
788
794
|
end
|
789
795
|
|
790
796
|
it "narrowed by != its cloned should be (== Nil)" do
|
@@ -794,41 +800,66 @@ module C
|
|
794
800
|
|
795
801
|
context "((< 10) && (> 0))" do
|
796
802
|
subject do
|
797
|
-
tmp =
|
798
|
-
tmp.intersection(
|
803
|
+
tmp = value_domain_greater_than(0)
|
804
|
+
tmp.intersection(value_domain_less_than(10))
|
799
805
|
end
|
800
806
|
|
801
807
|
it "+ ((< 10) && (> 0)) should be ((< 10) && (> 0))" do
|
802
|
-
rhs =
|
803
|
-
rhs = rhs.intersection(
|
808
|
+
rhs = value_domain_greater_than(0)
|
809
|
+
rhs = rhs.intersection(value_domain_less_than(10))
|
804
810
|
(subject + rhs).to_s.should == "((< 20) && (> 0))"
|
805
811
|
end
|
806
812
|
|
807
813
|
it "* (== 2) should be ((< 20) && (> 0))" do
|
808
|
-
rhs =
|
814
|
+
rhs = value_domain_equal_to(2)
|
809
815
|
(subject * rhs).to_s.should == "((< 20) && (> 0))"
|
810
816
|
end
|
811
817
|
|
812
818
|
it "* ((< 10) && (> 0)) should be ((< 100) && (> 0))" do
|
813
|
-
rhs =
|
814
|
-
rhs = rhs.intersection(
|
819
|
+
rhs = value_domain_greater_than(0)
|
820
|
+
rhs = rhs.intersection(value_domain_less_than(10))
|
815
821
|
(subject * rhs).to_s.should == "((< 100) && (> 0))"
|
816
822
|
end
|
817
823
|
|
818
824
|
it "/ (== 2) should be ((< 5) && (> 0))" do
|
819
|
-
rhs =
|
825
|
+
rhs = value_domain_equal_to(2)
|
820
826
|
(subject / rhs).to_s.should == "((< 5) && (> 0))"
|
821
827
|
end
|
822
828
|
|
823
829
|
# TODO: Fix bad value-domain division before 1.14.0 GA release.
|
824
830
|
#it "/ ((< 10) && (> 0)) should be ((< 10) && (> 0))" do
|
825
|
-
# rhs =
|
826
|
-
# rhs = rhs.intersection(
|
831
|
+
# rhs = value_domain_greater_than(0)
|
832
|
+
# rhs = rhs.intersection(value_domain_less_than(10))
|
827
833
|
# File.open("dump", "w") { |io| PP.pp(subject / rhs, io) }
|
828
834
|
# (subject / rhs).to_s.should == "((< 10) && (> 0))"
|
829
835
|
#end
|
830
836
|
end
|
831
837
|
end
|
838
|
+
|
839
|
+
private
|
840
|
+
def value_domain_equal_to(val)
|
841
|
+
ValueDomain.equal_to(val, logical_right_shift?)
|
842
|
+
end
|
843
|
+
|
844
|
+
def value_domain_less_than(val)
|
845
|
+
ValueDomain.less_than(val, logical_right_shift?)
|
846
|
+
end
|
847
|
+
|
848
|
+
def value_domain_greater_than(val)
|
849
|
+
ValueDomain.greater_than(val, logical_right_shift?)
|
850
|
+
end
|
851
|
+
|
852
|
+
def value_domain_less_than_or_equal_to(val)
|
853
|
+
ValueDomain.less_than_or_equal_to(val, logical_right_shift?)
|
854
|
+
end
|
855
|
+
|
856
|
+
def value_domain_greater_than_or_equal_to(val)
|
857
|
+
ValueDomain.greater_than_or_equal_to(val, logical_right_shift?)
|
858
|
+
end
|
859
|
+
|
860
|
+
def traits
|
861
|
+
@adlint.traits
|
862
|
+
end
|
832
863
|
end
|
833
864
|
|
834
865
|
end
|