Fossil SCM
| ca869aa… | drh | 1 | # |
| ca869aa… | drh | 2 | # Copyright (c) 2015 D. Richard Hipp |
| ca869aa… | drh | 3 | # |
| ca869aa… | drh | 4 | # This program is free software; you can redistribute it and/or |
| ca869aa… | drh | 5 | # modify it under the terms of the Simplified BSD License (also |
| ca869aa… | drh | 6 | # known as the "2-Clause License" or "FreeBSD License".) |
| ca869aa… | drh | 7 | # |
| ca869aa… | drh | 8 | # This program is distributed in the hope that it will be useful, |
| ca869aa… | drh | 9 | # but without any warranty; without even the implied warranty of |
| ca869aa… | drh | 10 | # merchantability or fitness for a particular purpose. |
| ca869aa… | drh | 11 | # |
| ca869aa… | drh | 12 | # Author contact information: |
| ca869aa… | drh | 13 | # [email protected] |
| ca869aa… | drh | 14 | # http://www.hwaci.com/drh/ |
| ca869aa… | drh | 15 | # |
| ca869aa… | drh | 16 | ############################################################################ |
| ca869aa… | drh | 17 | # |
| ca869aa… | drh | 18 | # Test containsSelector() function in src/style.c |
| ca869aa… | drh | 19 | # |
| ca869aa… | drh | 20 | |
| fa59221… | mistachkin | 21 | test_setup "" |
| fa59221… | mistachkin | 22 | |
| ca869aa… | drh | 23 | proc contains-selector {testId css selectorResultMap} { |
| ca869aa… | drh | 24 | set css [string trim $css] |
| ca869aa… | drh | 25 | set filename [file join $::tempPath compare-selector.css] |
| ca869aa… | drh | 26 | set fh [open $filename w] |
| ca869aa… | drh | 27 | puts -nonewline $fh $css |
| ca869aa… | drh | 28 | close $fh |
| ca869aa… | drh | 29 | foreach {selector found} $selectorResultMap { |
| ca869aa… | drh | 30 | set expected "$selector [expr {$found ? "found" : "not found"}]" |
| ca869aa… | drh | 31 | set result [fossil test-contains-selector $filename $selector] |
| ca869aa… | drh | 32 | test "contains-selector $testId $selector" {$result eq $expected} |
| ca869aa… | drh | 33 | } |
| ca869aa… | drh | 34 | file delete $filename |
| ca869aa… | drh | 35 | } |
| ca869aa… | drh | 36 | |
| ca869aa… | drh | 37 | contains-selector 1 { |
| ca869aa… | drh | 38 | .a.b {} |
| ca869aa… | drh | 39 | .c .de {} |
| ca869aa… | drh | 40 | /* comment */ |
| ca869aa… | drh | 41 | .c .d, .e /* comment */ {} |
| ca869aa… | drh | 42 | } { |
| ca869aa… | drh | 43 | .a 0 |
| ca869aa… | drh | 44 | .b 0 |
| ca869aa… | drh | 45 | .a.b 1 |
| ca869aa… | drh | 46 | .c 0 |
| ca869aa… | drh | 47 | .d 0 |
| ca869aa… | drh | 48 | {.c.d} 0 |
| ca869aa… | drh | 49 | {.c .d} 1 |
| ca869aa… | drh | 50 | .e 1 |
| ca869aa… | drh | 51 | } |
| fa59221… | mistachkin | 52 | |
| fa59221… | mistachkin | 53 | ############################################################################### |
| fa59221… | mistachkin | 54 | |
| fa59221… | mistachkin | 55 | test_cleanup |