| 1 | # $Id: lastpos 2413 2010-09-11 17:43:04Z bird $                                        -*-perl-*- | 
|---|
| 2 | ## @file | 
|---|
| 3 | # $(lastpos needle, haystack[, start]) | 
|---|
| 4 | # | 
|---|
| 5 |  | 
|---|
| 6 | # | 
|---|
| 7 | # Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> | 
|---|
| 8 | # | 
|---|
| 9 | # This file is part of kBuild. | 
|---|
| 10 | # | 
|---|
| 11 | # kBuild is free software; you can redistribute it and/or modify | 
|---|
| 12 | # it under the terms of the GNU General Public License as published by | 
|---|
| 13 | # the Free Software Foundation; either version 3 of the License, or | 
|---|
| 14 | # (at your option) any later version. | 
|---|
| 15 | # | 
|---|
| 16 | # kBuild is distributed in the hope that it will be useful, | 
|---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 19 | # GNU General Public License for more details. | 
|---|
| 20 | # | 
|---|
| 21 | # You should have received a copy of the GNU General Public License | 
|---|
| 22 | # along with kBuild.  If not, see <http://www.gnu.org/licenses/> | 
|---|
| 23 | # | 
|---|
| 24 | # | 
|---|
| 25 |  | 
|---|
| 26 | $description = "Tests the $(lastpos ) function"; | 
|---|
| 27 |  | 
|---|
| 28 | $details = "A few simple tests, nothing spectacular."; | 
|---|
| 29 |  | 
|---|
| 30 | if ($is_kmk) { | 
|---|
| 31 |  | 
|---|
| 32 | # TEST #0 - check that the feature is present. | 
|---|
| 33 | # -------------------------------------------- | 
|---|
| 34 | run_make_test(' | 
|---|
| 35 | ifneq ($(lastpos b,abc),2) | 
|---|
| 36 | $(error sub-test 0 failed) | 
|---|
| 37 | endif | 
|---|
| 38 | .PHONY: all | 
|---|
| 39 | all: ; @: | 
|---|
| 40 | ', | 
|---|
| 41 | '', | 
|---|
| 42 | ''); | 
|---|
| 43 |  | 
|---|
| 44 | # TEST #1 - the real test. | 
|---|
| 45 | # ------------------------ | 
|---|
| 46 | run_make_test(' | 
|---|
| 47 | ifneq ($(lastpos t,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 48 | $(error sub-test 0 failed) | 
|---|
| 49 | endif | 
|---|
| 50 | ifneq ($(lastpos tu,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 51 | $(error sub-test 1 failed) | 
|---|
| 52 | endif | 
|---|
| 53 | ifneq ($(lastpos tuv,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 54 | $(error sub-test 2 failed) | 
|---|
| 55 | endif | 
|---|
| 56 | ifneq ($(lastpos tuvw,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 57 | $(error sub-test 3 failed) | 
|---|
| 58 | endif | 
|---|
| 59 | ifneq ($(lastpos tuvwx,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 60 | $(error sub-test 4 failed) | 
|---|
| 61 | endif | 
|---|
| 62 | ifneq ($(lastpos tuvwxy,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 63 | $(error sub-test 5 failed) | 
|---|
| 64 | endif | 
|---|
| 65 | ifneq ($(lastpos tuvwxyz,abcdefghijklmnopqrstuvwxyz),20) | 
|---|
| 66 | $(error sub-test 6 failed) | 
|---|
| 67 | endif | 
|---|
| 68 | ifneq ($(lastpos tuvwxyz!,abcdefghijklmnopqrstuvwxyz),0) | 
|---|
| 69 | $(error sub-test 7 failed) | 
|---|
| 70 | endif | 
|---|
| 71 |  | 
|---|
| 72 | ifneq ($(lastpos a,ababababab),9) | 
|---|
| 73 | $(error sub-test 10 failed) | 
|---|
| 74 | endif | 
|---|
| 75 | ifneq ($(lastpos a,ababababab,8),7) | 
|---|
| 76 | $(error sub-test 11 failed) | 
|---|
| 77 | endif | 
|---|
| 78 | ifneq ($(lastpos a,ababababab,7),7) | 
|---|
| 79 | $(error sub-test 12 failed) | 
|---|
| 80 | endif | 
|---|
| 81 | ifneq ($(lastpos a,ababababab,4),3) | 
|---|
| 82 | $(error sub-test 13 failed) | 
|---|
| 83 | endif | 
|---|
| 84 | ifneq ($(lastpos a,ababababab,3),3) | 
|---|
| 85 | $(error sub-test 14 failed) | 
|---|
| 86 | endif | 
|---|
| 87 | ifneq ($(lastpos a,ababababab,2),1) | 
|---|
| 88 | $(error sub-test 15 failed) | 
|---|
| 89 | endif | 
|---|
| 90 | ifneq ($(lastpos a,ababababab,1),1) | 
|---|
| 91 | $(error sub-test 16 failed) | 
|---|
| 92 | endif | 
|---|
| 93 | ifneq ($(lastpos a,ababababab,-1),9) | 
|---|
| 94 | $(error sub-test 17 failed) | 
|---|
| 95 | endif | 
|---|
| 96 | ifneq ($(lastpos a,ababababab,-2),9) | 
|---|
| 97 | $(error sub-test 18 failed) | 
|---|
| 98 | endif | 
|---|
| 99 | ifneq ($(lastpos a,ababababab,-10),1) | 
|---|
| 100 | $(error sub-test 19 failed) | 
|---|
| 101 | endif | 
|---|
| 102 | ifneq ($(lastpos a,ababababab,-11),0) | 
|---|
| 103 | $(error sub-test 20 failed) | 
|---|
| 104 | endif | 
|---|
| 105 |  | 
|---|
| 106 |  | 
|---|
| 107 | .PHONY: all | 
|---|
| 108 | all: ; @: | 
|---|
| 109 | ', | 
|---|
| 110 | '', | 
|---|
| 111 | ''); | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | # Indicate that we're done. | 
|---|
| 117 | 1; | 
|---|
| 118 |  | 
|---|