Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TESTS: added initial append tests

  • Loading branch information...
commit d70332b64fa22332e2d1456537fc51c68645a63e 1 parent 63b712e
@PeterWAWood PeterWAWood authored
View
2  red/tests/run-all.r
@@ -66,6 +66,7 @@ start-time: now/precise
--run-test-file-quiet-red %source/units/switch-test.red
--run-test-file-quiet-red %source/units/case-test.red
--run-test-file-quiet-red %source/units/routine-test.red
+ --run-test-file-quiet-red %source/units/append-test.red
===end-group===
===start-group=== "Auto-tests"
@@ -99,6 +100,7 @@ start-time: now/precise
--run-test-file-quiet-red %source/units/auto-tests/interpreter-series-test.red
--run-test-file-quiet-red %source/units/auto-tests/interpreter-type-test.red
--run-test-file-quiet-red %source/units/auto-tests/interpreter-switch-test.red
+ --run-test-file-quiet-red %source/units/auto-tests/interpreter-append-test.red
--run-test-file-quiet-red %source/units/auto-tests/interp-equal-auto-test.red
--run-test-file-quiet-red %source/units/auto-tests/interp-greater-auto-test.red
--run-test-file-quiet-red %source/units/auto-tests/interp-inf-equal-auto-test.red
View
100 red/tests/source/units/append-test.red
@@ -0,0 +1,100 @@
+Red [
+ Title: "Red append test script"
+ Author: "Nenad Rakocevic & Peter W A Wood"
+ File: %append-test.red
+ Tabs: 4
+ Rights: "Copyright (C) 2011-2013 Nenad Rakocevic & Peter W A Wood. All rights reserved."
+ License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
+]
+
+#include %../../../../quick-test/quick-test.red
+
+~~~start-file~~~ "append"
+
+===start-group=== "append"
+ --test-- "append-1"
+ --assert 6 = last append [1 2 3 4 5] 6
+ --test-- "append-2"
+ --assert 6 = last append [1 2 3 4] [5 6]
+ --assert 4 = fourth append [1 2 3 4] [5 6]
+ --assert 5 = fifth append [1 2 3 4] [5 6]
+ --test-- "append-3"
+ --assert 55 = last append "12345" "67"
+ --test-- "append-4"
+ --assert 233 = last append "abcde" "é" ;; utf-8 C3 A9
+ --test-- "append-5"
+ --assert 49 = last append "abcdeé" "1" ;; utf-8 C3 A9
+ --test-- "append-6"
+ --assert 10000 = last append "abcde" "✐"
+ --test-- "append-7"
+ --assert 48 = last append "abcde^(2710)" "0"
+ --test-- "append-8"
+ --assert 10000 = last append "abcdeé" "^(2710)"
+ --test-- "append-9"
+ --assert 233 = last append "abcde^(2710)" "é"
+ --test-- "append-10"
+ --assert 65536 = last append "abcde" "^(010000)"
+ --test-- "append-11"
+ --assert 48 = last append "abcde^(010000)" "0"
+ --test-- "append-12"
+ --assert 65536 = last append "abcde^(2710)é" "^(010000)"
+
+ --test-- "append-13"
+ blk: make block! 1
+ append blk 'x/y
+ append/only blk 'r/s
+ --assert "[x y r/s]" = mold blk
+
+ --test-- "append-14"
+ blk: [1 2]
+ append/dup/part blk [4 5 6] 3 2
+ --assert "[1 2 4 5 4 5 4 5]" = mold blk
+
+ --test-- "append-15"
+ blk: [1 2]
+ append/dup/part blk [4 5 6] 2 3
+ --assert "[1 2 4 5 6 4 5 6]" = mold blk
+
+ --test-- "append-16"
+ str: "12"
+ append/dup/part str "456" 3 2
+ --assert str = "12454545"
+
+ --test-- "append-17"
+ str: "12"
+ append/part/dup str "456" 3 2
+ --assert str = "12456456"
+
+===end-group===
+
+===start-group=== "append/dup"
+
+ --test-- "append/dup1"
+ ad1-s: copy ""
+ append/dup ad1-s #" " 10
+ --assert 10 = length? ad1-s
+ --assert " " = ad1-s
+
+ --test-- "append/dup2"
+ ad2-s: copy ""
+ append/dup ad2-s #"1" 9
+
+ --assert 9 = length? ad2-s
+ --assert "111111111" = ad2-s
+
+ --test-- "append/dup2"
+ ad3-s: copy []
+ append/dup ad3-s 1 8
+ --assert 8 = length? ad3-s
+ --assert [1 1 1 1 1 1 1 1] = ad3-s
+
+ --test-- "append/dup4"
+ ad4-s: copy " "
+ append/dup ad4-s #" " 10
+ --assert 11 = length? ad4-s
+ --assert " " = ad4-s
+
+===end-group===
+
+~~~end-file~~~
+
View
3  red/tests/source/units/make-interpreter-auto-test.r
@@ -27,7 +27,8 @@ file-list: [
%serialization-test.red %auto-tests/interpreter-serialization-test.red
%series-test.red %auto-tests/interpreter-series-test.red
%type-test.red %auto-tests/interpreter-type-test.red
- %switch-test.red %auto-tests/interpreter-switch-test.red
+ %switch-test.red %auto-tests/interpreter-switch-test.red
+ %append-test.red %auto-tests/interpreter-append-test.red
%auto-tests/equal-auto-test.red %auto-tests/interp-equal-auto-test.red
%auto-tests/greater-auto-test.red %auto-tests/interp-greater-auto-test.red
%auto-tests/infix-equal-auto-test.red %auto-tests/interp-inf-equal-auto-test.red
View
2  red/tests/source/units/series-test.red
@@ -1,5 +1,5 @@
Red [
- Title: "Red case series test script"
+ Title: "Red series test script"
Author: "Nenad Rakocevic & Peter W A Wood"
File: %series-test.red
Tabs: 4
Please sign in to comment.
Something went wrong with that request. Please try again.