1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006 Floréal Morandat <morandat@lirmm.fr>
4 # Copyright 2008 Jean Privat <jean@pryen.org>
5 # Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
21 var s
= "totototo.nit"
25 print
("substring: {s.substring(-1,5)}")
26 print
("substring_from: {s.substring_from(4)}")
27 print
("has_substring: {s.has_substring(p,4)}")
28 print
("has_substring: {s.has_substring(p,0)}")
29 print
("has_substring: {s.has_substring(p,1)}")
30 print
("has_prefix: {s.has_prefix(p)}")
31 print
("has_prefix: {s.has_prefix(e)}")
32 print
("has_suffix: {s.has_suffix(e)}")
33 print
("has_suffix: {s.has_suffix(p)}")
37 print
("test[0] == 't' => {test[0] == 't'}")
38 print
("test[1] == 'e' => {test[1] == 'e'}")
39 print
("test[2] == 's' => {test[2] == 's'}")
40 print
("test[3] == 't' => {test[3] == 't'}")
42 print
("test.substring(0,1) == \"t\
" => {test.substring(0,1) == "t"}")
43 print
("test.substring(0,2) == \"te\
" => {test.substring(0,2) == "te"}")
44 print
("test.substring(0,3) == \"tes\
" => {test.substring(0,3) == "tes"}")
45 print
("test.substring(0,4) == \"test\
" => {test.substring(0,4) == "test"}")
47 print
("test.has_substring(\"t\
", 0) => {test.has_substring("t", 0)}")
48 print
("test.has_substring(\"te\
", 0) => {test.has_substring("te", 0)}")
49 print
("test.has_substring(\"tes\
", 0) => {test.has_substring("tes", 0)}")
50 print
("test.has_substring(\"test\
", 0) => {test.has_substring("test", 0)}")
51 print
("test.has_substring(\"e\
", 1) => {test.has_substring("e", 1)}")
52 print
("test.has_substring(\"es\
", 1) => {test.has_substring("es", 1)}")
53 print
("test.has_substring(\"est\
", 1) => {test.has_substring("est", 1)}")
54 print
("test.has_substring(\"s\
", 2) => {test.has_substring("s", 2)}")
55 print
("test.has_substring(\"st\
", 2) => {test.has_substring("st", 2)}")
56 print
("test.has_substring(\"t\
", 3) => {test.has_substring("t", 3)}")
57 print
("test.has_substring(\"z\
", 3) => {test.has_substring("z", 3)}")
58 print
("test.has_substring(\"ze\
", 0) => {test.has_substring("ze", 0)}")
59 print
("test.has_substring(\"bas\
", 0) => {test.has_substring("bas", 0)}")
60 print
("test.has_substring(\"foot\
", 0) => {test.has_substring("foot", 0)}")
62 print
("test.has_prefix(\"t\
") => {test.has_prefix("t")}")
63 print
("test.has_prefix(\"te\
") => {test.has_prefix("te")}")
64 print
("test.has_prefix(\"tes\
") => {test.has_prefix("tes")}")
65 print
("test.has_prefix(\"test\
") => {test.has_prefix("test")}")
66 print
("test.has_prefix(\"ze\
") => {test.has_prefix("ze")}")
67 print
("test.has_prefix(\"bas\
") => {test.has_prefix("bas")}")
68 print
("test.has_prefix(\"foot\
") => {test.has_prefix("foot")}")
70 print
("test.has_suffix(\"t\
") => {test.has_suffix("t")}")
71 print
("test.has_suffix(\"st\
") => {test.has_suffix("st")}")
72 print
("test.has_suffix(\"est\
") => {test.has_suffix("est")}")
73 print
("test.has_suffix(\"test\
") => {test.has_suffix("test")}")
74 print
("test.has_suffix(\"bt\
") => {test.has_suffix("bt")}")
75 print
("test.has_suffix(\"bat\
") => {test.has_suffix("bat")}")
76 print
("test.has_suffix(\"foot\
") => {test.has_suffix("foot")}")