diff options
Diffstat (limited to 'test/Moretest')
-rw-r--r-- | test/Moretest/Makefile | 13 | ||||
-rw-r--r-- | test/Moretest/regexp.ml | 12 | ||||
-rw-r--r-- | test/Moretest/tformat.ml | 33 | ||||
-rw-r--r-- | test/Moretest/tscanf.ml | 49 |
4 files changed, 103 insertions, 4 deletions
diff --git a/test/Moretest/Makefile b/test/Moretest/Makefile index 86014fd9a..5074d8d55 100644 --- a/test/Moretest/Makefile +++ b/test/Moretest/Makefile @@ -14,9 +14,9 @@ include ../../config/Makefile -CAMLC=../../boot/ocamlrun ../../ocamlc -I ../../stdlib +CAMLC=../../boot/ocamlrun ../../ocamlc -I ../../stdlib -I ../../otherlibs/unix BYTEFLAGS=-g -CAMLOPT=../../boot/ocamlrun ../../ocamlopt -I ../../stdlib +CAMLOPT=../../boot/ocamlrun ../../ocamlopt -I ../../stdlib -I ../../otherlibs/unix OPTFLAGS=-S -g CAMLDEP=../../boot/ocamlrun ../../tools/ocamldep CAMLRUN=../../byterun/ocamlrun @@ -152,6 +152,15 @@ printf: tprintf.byt tprintf.bin ./tprintf.byt ./tprintf.bin +tformat.byt: testing.cmo tformat.cmo + ${CAMLC} -o tformat.byt testing.cmo tformat.cmo +tformat.bin: testing.cmx tformat.cmx + ${CAMLOPT} -o tformat.bin testing.cmx tformat.cmx + +format: tformat.byt tformat.bin + ./tformat.byt + ./tformat.bin + tbuffer.byt: testing.cmo tbuffer.cmo ${CAMLC} -o tbuffer.byt testing.cmo tbuffer.cmo tbuffer.bin: testing.cmx tbuffer.cmx diff --git a/test/Moretest/regexp.ml b/test/Moretest/regexp.ml index 7cb75b8ad..bb266a017 100644 --- a/test/Moretest/regexp.ml +++ b/test/Moretest/regexp.ml @@ -289,6 +289,18 @@ let automated_test() = test_search_forward r n "babababc" [||]; + start_test "Search for /[^a]/"; + let r = Str.regexp "[^a]" in + let n = 0 in + test_search_forward r n "athing" [|"t"|]; + test_search_forward r n "Athing" [|"A"|]; + + start_test "Search for /[^a]/ (case-insensitive)"; + let r = Str.regexp_case_fold "[^a]" in + let n = 0 in + test_search_forward r n "athing" [|"t"|]; + test_search_forward r n "Athing" [|"t"|]; + start_test "Search for /^[]abcde]/"; let r = Str.regexp "^[]abcde]" in let n = 0 in diff --git a/test/Moretest/tformat.ml b/test/Moretest/tformat.ml new file mode 100644 index 000000000..d02cb2907 --- /dev/null +++ b/test/Moretest/tformat.ml @@ -0,0 +1,33 @@ +(*************************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Pierre Weis, projet Estime, INRIA Rocquencourt *) +(* *) +(* Copyright 2009 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(*************************************************************************) + +(* $Id$ + +A testbed file for the module Format. + +*) + +open Testing;; + +open Format;; + +(* BR#4769 *) +let test0 () = + let b = Buffer.create 10 in + let msg = "Hello world!" in + Format.bprintf b "%s" msg; + let s = Buffer.contents b in + s = msg +;; + +test (test0 ()) +;; diff --git a/test/Moretest/tscanf.ml b/test/Moretest/tscanf.ml index dd7d2a60b..34e28d8a9 100644 --- a/test/Moretest/tscanf.ml +++ b/test/Moretest/tscanf.ml @@ -1,8 +1,20 @@ +(*************************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Pierre Weis, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(*************************************************************************) + (* $Id$ -A testbed file for module Scanf. +A testbed file for the module Scanf. - *) +*) open Testing;; @@ -1165,6 +1177,39 @@ let test56 () = test (test56 ()) ;; +(* Testing the scanning of formats. *) +let test48 () = + (* Testing format_from_string. *) + let test_format_scan s fmt efmt = + format_from_string s fmt = efmt in + (* Test if format %i is indeed read as %i. *) + let s, fmt = " %i ", format_of_string "%i" in + test_format_scan s fmt " %i " && + (* Test if format %i is compatible with %d and indeed read as %i. *) + let s, fmt = "%i", format_of_string "%d" in + test_format_scan s fmt "%i" && + + let s, fmt = + "Read an int %i then a string %s.", + format_of_string "Spec%difi%scation" in + test_format_scan s fmt "Read an int %i then a string %s." && + + let s, fmt = + "Read an int %i then a string \"%s\".", + format_of_string "Spec%difi%Scation" in + test_format_scan s fmt "Read an int %i then a string \"%s\"." && + + let s, fmt = + "Read an int %i then a string \"%s\".", + format_of_string "Spec%difi%scation" in + test_format_scan s fmt "Read an int %i then a string \"%s\"." && + + (* Complex test of scanning a meta format specified in the scanner input + format string and extraction of its specification from a string. *) + sscanf "12 \"%i\"89 " "%i %{%d%}%s %!" + (fun i f s -> i = 12 && f = "%i" && s = "89") +;; + (* To be continued ... (* Trying to scan records. *) let rec scan_fields ib scan_field accu = |