]> granicus.if.org Git - vim/commitdiff
patch 8.2.1316: test 42 is still old style v8.2.1316
authorBram Moolenaar <Bram@vim.org>
Wed, 29 Jul 2020 14:08:21 +0000 (16:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 Jul 2020 14:08:21 +0000 (16:08 +0200)
Problem:    Test 42 is still old style.
Solution:   Turn it into a new style test. (Yegappan Lakshmanan, closes #6561)

src/Makefile
src/testdir/Make_all.mak
src/testdir/Make_dos.mak
src/testdir/Make_ming.mak
src/testdir/Make_vms.mms
src/testdir/test42.in [deleted file]
src/testdir/test42.ok [deleted file]
src/testdir/test_writefile.vim
src/version.c

index bbf80d32632b09b09fc6f85be148ef3b5005de04..d34a60891bf294434547964f0e53c0dcd03f7a7f 100644 (file)
@@ -2310,7 +2310,7 @@ test_libvterm:
 
 # Run individual OLD style test.
 # These do not depend on the executable, compile it when needed.
-test1 test42 test49 test59:
+test1 test49 test59:
        cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
 
 # Run individual NEW style test.
index a25a480dd312dbff972cf45672c0c2db09dfdcbd..635087cbdc0fea7a8a6395d284431f7f3e52e09e 100644 (file)
@@ -11,7 +11,7 @@ NO_INITS = -U NONE $(NO_PLUGINS)
 SCRIPTS_FIRST = test1.out
 
 # Tests that run on all systems.
-SCRIPTS_ALL = test42.out
+SCRIPTS_ALL =
 
 # Tests that run on most systems, but not on Amiga.
 SCRIPTS_MORE1 =
index 0e07ed5c5f1508cb44a5986d133186cbd86bd46f..f97b3e9bb4a2a4b0f9bf072a8f73d5faf0dc6dbb 100644 (file)
@@ -10,10 +10,7 @@ default: nongui
 !include Make_all.mak
 
 # Omitted:
-# test2                "\\tmp" doesn't work.
-# test10       'errorformat' is different
 # test49       fails in various ways
-# test97       \{ and \$ are not escaped characters.
 
 SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4)
 
index f95f70c88c426490637736f2cda348849882a260..e1f34674920ea37bc75f620977a9bf7276e87860 100644 (file)
@@ -28,11 +28,6 @@ default: vimall
 
 include Make_all.mak
 
-# Omitted:
-# test2                "\\tmp" doesn't work.
-# test10       'errorformat' is different
-# test97       \{ and \$ are not escaped characters
-
 SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
 
 SCRIPTS_BENCH = test_bench_regexp.res
index af76f703ad46b73bbf55c9da3ee6061daa73cf64..848fca7f5829bcf0cd630e18e27e7078d42ee90c 100644 (file)
@@ -73,8 +73,7 @@ VIMPROG = <->vim.exe
 
 .SUFFIXES : .out .in
 
-SCRIPT = test1.out \
-       test42.out test49.out test77a.out
+SCRIPT = test1.out test49.out test77a.out
 
 # Known problems:
 #
diff --git a/src/testdir/test42.in b/src/testdir/test42.in
deleted file mode 100644 (file)
index 1d9d3ab..0000000
Binary files a/src/testdir/test42.in and /dev/null differ
diff --git a/src/testdir/test42.ok b/src/testdir/test42.ok
deleted file mode 100644 (file)
index 183430d..0000000
Binary files a/src/testdir/test42.ok and /dev/null differ
index d92d6aedbe59348ebb86384efa5246f26e75aa8e..d6e7e64c11beff197030e9f13e9400562a741a31 100644 (file)
@@ -556,4 +556,132 @@ func Test_write_file_encoding()
   %bw!
 endfunc
 
+" Test for writing and reading a file starting with a BOM.
+" Byte Order Mark (BOM) character for various encodings is below:
+"     UTF-8      : EF BB BF
+"     UTF-16 (BE): FE FF
+"     UTF-16 (LE): FF FE
+"     UTF-32 (BE): 00 00 FE FF
+"     UTF-32 (LE): FF FE 00 00
+func Test_readwrite_file_with_bom()
+  let utf8_bom = "\xEF\xBB\xBF"
+  let utf16be_bom = "\xFE\xFF"
+  let utf16le_bom = "\xFF\xFE"
+  let utf32be_bom = "\n\n\xFE\xFF"
+  let utf32le_bom = "\xFF\xFE\n\n"
+  let save_fileencoding = &fileencoding
+  set cpoptions+=S
+
+  " Check that editing a latin1 file doesn't see a BOM
+  call writefile(["\xFE\xFElatin-1"], 'Xtest1')
+  edit Xtest1
+  call assert_equal('latin1', &fileencoding)
+  call assert_equal(0, &bomb)
+  set fenc=latin1
+  write Xfile2
+  call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xfile2', 'b'))
+  set bomb fenc=latin1
+  write Xtest3
+  call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xtest3', 'b'))
+  set bomb&
+
+  " Check utf-8 BOM
+  %bw!
+  call writefile([utf8_bom .. "utf-8"], 'Xtest1')
+  edit! Xtest1
+  call assert_equal('utf-8', &fileencoding)
+  call assert_equal(1, &bomb)
+  call assert_equal('utf-8', getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal(['utf-8', ''], readfile('Xfile2', 'b'))
+  set fenc=utf-8
+  w! Xtest3
+  call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xtest3', 'b'))
+
+  " Check utf-8 with an error (will fall back to latin-1)
+  %bw!
+  call writefile([utf8_bom .. "utf-8\x80err"], 'Xtest1')
+  edit! Xtest1
+  call assert_equal('latin1', &fileencoding)
+  call assert_equal(0, &bomb)
+  call assert_equal("\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xfile2', 'b'))
+  set fenc=utf-8
+  w! Xtest3
+  call assert_equal(["\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", ''],
+        \ readfile('Xtest3', 'b'))
+
+  " Check ucs-2 BOM
+  %bw!
+  call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xtest1')
+  edit! Xtest1
+  call assert_equal('utf-16', &fileencoding)
+  call assert_equal(1, &bomb)
+  call assert_equal('ucs-2', getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal(["ucs-2", ''], readfile('Xfile2', 'b'))
+  set fenc=ucs-2
+  w! Xtest3
+  call assert_equal([utf16be_bom .. "\nu\nc\ns\n-\n2\n", ''],
+        \ readfile('Xtest3', 'b'))
+
+  " Check ucs-2le BOM
+  %bw!
+  call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xtest1')
+  " Need to add a NUL byte after the NL byte
+  call writefile(0z00, 'Xtest1', 'a')
+  edit! Xtest1
+  call assert_equal('utf-16le', &fileencoding)
+  call assert_equal(1, &bomb)
+  call assert_equal('ucs-2le', getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal(["ucs-2le", ''], readfile('Xfile2', 'b'))
+  set fenc=ucs-2le
+  w! Xtest3
+  call assert_equal([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n", "\n"],
+        \ readfile('Xtest3', 'b'))
+
+  " Check ucs-4 BOM
+  %bw!
+  call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xtest1')
+  edit! Xtest1
+  call assert_equal('ucs-4', &fileencoding)
+  call assert_equal(1, &bomb)
+  call assert_equal('ucs-4', getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal(["ucs-4", ''], readfile('Xfile2', 'b'))
+  set fenc=ucs-4
+  w! Xtest3
+  call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xtest3', 'b'))
+
+  " Check ucs-4le BOM
+  %bw!
+  call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xtest1')
+  " Need to add three NUL bytes after the NL byte
+  call writefile(0z000000, 'Xtest1', 'a')
+  edit! Xtest1
+  call assert_equal('ucs-4le', &fileencoding)
+  call assert_equal(1, &bomb)
+  call assert_equal('ucs-4le', getline(1))
+  set fenc=latin1
+  write! Xfile2
+  call assert_equal(["ucs-4le", ''], readfile('Xfile2', 'b'))
+  set fenc=ucs-4le
+  w! Xtest3
+  call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b'))
+
+  set cpoptions-=S
+  let &fileencoding = save_fileencoding
+  call delete('Xtest1')
+  call delete('Xtest2')
+  call delete('Xtest3')
+  %bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 12716683573bfb23a337866aad9a23f83bf1eae5..045dfbcb78d10a45d1ea27b6aa8bd7ac83eec088 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1316,
 /**/
     1315,
 /**/