/red-system/tests/source/units/not-test.reds

http://github.com/dockimbel/Red · Redscript · 65 lines · 49 code · 16 blank · 0 comment · 3 complexity · 84b73dab1fa3cd2507e6a65184d6d62d MD5 · raw file

  1. Red/System [
  2. Title: "Red/System NOT function test script"
  3. Author: "Nenad Rakocevic"
  4. File: %not-test.reds
  5. Rights: "Copyright (C) 2011 Nenad Rakocevic. All rights reserved."
  6. License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
  7. ]
  8. #include %../../../../quick-test/quick-test.reds
  9. not-foo: func [a [logic!] return: [logic!]][a]
  10. not-nfoo: func [a [logic!] return: [logic!]][not a]
  11. ~~~start-file~~~ "not"
  12. --test-- "not-1" --assert false = not true
  13. --test-- "not-2" --assert not false
  14. --test-- "not-3" --assert not not true
  15. --test-- "not-4" --assert false = not not false
  16. --test-- "not-5"
  17. n-logic-a: true
  18. --assert false = not n-logic-a
  19. --test-- "not-6"
  20. n-logic-a: false
  21. --assert not n-logic-a
  22. --test-- "not-7" --assert false = not not-foo true
  23. --test-- "not-8" --assert not not-foo false
  24. --test-- "not-9" --assert false = not-foo not true
  25. --test-- "not-10" --assert not-foo not false
  26. --test-- "not-11"
  27. n-logic-a: true
  28. --assert false = not not-foo n-logic-a
  29. --test-- "not-12"
  30. n-logic-a: true
  31. --assert false = not-foo not n-logic-a
  32. --test-- "not-13"
  33. n-logic-a: false
  34. --assert not not-foo n-logic-a
  35. --test-- "not-14"
  36. n-logic-a: false
  37. --assert not not-foo n-logic-a
  38. --test-- "not-15" --assert false = not-nfoo true
  39. --test-- "not-16" --assert not-nfoo false
  40. --test-- "not-17" --assert false = not-nfoo true
  41. --test-- "not-18" --assert not-nfoo false
  42. --test-- "not-19" --assert -1 = (not 4 and 3)
  43. --test-- "not-20" --assert -5 = not 4
  44. --test-- "not-21" --assert 3 = (-5 and 3)
  45. --test-- "not-22" --assert 3 = (3 and -5)
  46. --test-- "not-23" --assert 3 = (3 and not 4)
  47. --test-- "not-24" --assert 0 = (4 and 3)
  48. ~~~end-file~~~
  49. ;TBD: write unit tests for bitwise NOT on integer