Fossil SCM
Another test-case which gave an expected error-message, with fix: before: $ fossil test-th-eval "expr 0+0b" TH_ERROR: syntax error in expression: "0+0b" after: $ ./fossil test-th-eval "expr 0+0b" TH_ERROR: expected number, got: "0b"
Commit
b78ae90a84d5b0551f31b187b7f08fd6a9471e29
Parent
0f3ed70be4027ee…
2 files changed
+1
-1
+8
M
src/th.c
+1
-1
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -1882,11 +1882,11 @@ | ||
| 1882 | 1882 | ){ |
| 1883 | 1883 | int i; |
| 1884 | 1884 | int (*isdigit)(char) = th_isdigit; |
| 1885 | 1885 | char c; |
| 1886 | 1886 | |
| 1887 | - if( nInput<3) return TH_ERROR; | |
| 1887 | + if( nInput<2) return TH_ERROR; | |
| 1888 | 1888 | assert(zInput[0]=='0'); |
| 1889 | 1889 | c = zInput[1]; |
| 1890 | 1890 | if( c>='A' && c<='Z' ) c += 'a' - 'A'; |
| 1891 | 1891 | if( c=='x' ){ |
| 1892 | 1892 | isdigit = th_ishexdig; |
| 1893 | 1893 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1882,11 +1882,11 @@ | |
| 1882 | ){ |
| 1883 | int i; |
| 1884 | int (*isdigit)(char) = th_isdigit; |
| 1885 | char c; |
| 1886 | |
| 1887 | if( nInput<3) return TH_ERROR; |
| 1888 | assert(zInput[0]=='0'); |
| 1889 | c = zInput[1]; |
| 1890 | if( c>='A' && c<='Z' ) c += 'a' - 'A'; |
| 1891 | if( c=='x' ){ |
| 1892 | isdigit = th_ishexdig; |
| 1893 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -1882,11 +1882,11 @@ | |
| 1882 | ){ |
| 1883 | int i; |
| 1884 | int (*isdigit)(char) = th_isdigit; |
| 1885 | char c; |
| 1886 | |
| 1887 | if( nInput<2) return TH_ERROR; |
| 1888 | assert(zInput[0]=='0'); |
| 1889 | c = zInput[1]; |
| 1890 | if( c>='A' && c<='Z' ) c += 'a' - 'A'; |
| 1891 | if( c=='x' ){ |
| 1892 | isdigit = th_ishexdig; |
| 1893 |
+8
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -467,5 +467,13 @@ | ||
| 467 | 467 | |
| 468 | 468 | ############################################################################### |
| 469 | 469 | |
| 470 | 470 | fossil test-th-eval "expr 0b1+5" |
| 471 | 471 | test th1-expr-34 {$RESULT eq {6}} |
| 472 | + | |
| 473 | + | |
| 474 | +############################################################################### | |
| 475 | + | |
| 476 | +fossil test-th-eval "expr 0+0b" | |
| 477 | +test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} | |
| 478 | + | |
| 479 | + | |
| 472 | 480 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -467,5 +467,13 @@ | |
| 467 | |
| 468 | ############################################################################### |
| 469 | |
| 470 | fossil test-th-eval "expr 0b1+5" |
| 471 | test th1-expr-34 {$RESULT eq {6}} |
| 472 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -467,5 +467,13 @@ | |
| 467 | |
| 468 | ############################################################################### |
| 469 | |
| 470 | fossil test-th-eval "expr 0b1+5" |
| 471 | test th1-expr-34 {$RESULT eq {6}} |
| 472 | |
| 473 | |
| 474 | ############################################################################### |
| 475 | |
| 476 | fossil test-th-eval "expr 0+0b" |
| 477 | test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} |
| 478 | |
| 479 | |
| 480 |