1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
;;; ess-test-r-tokens.el --- ESS tests for R tokens -*- lexical-binding: t; -*-
;;
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; A copy of the GNU General Public License is available at
;; https://www.r-project.org/Licenses/
;;
;;; Commentary:
;;
(require 'ert)
(require 'etest)
(require 'ess-r-mode)
(require 'ess-test-r-utils)
(etest-deftest ess-r-syntax-backslash-test ()
:case "sapply(x, ¶\\(y) y"
(should (equal (syntax-after (point))
(string-to-syntax ".")))
:case "c(\"¶\\\"\")"
(should (equal (syntax-after (point))
(string-to-syntax "\\"))))
(etest-deftest ess-r-font-lock-boolean-operator-test ()
:case "foo ¶| foo ¶|¶| foo ¶& foo ¶&¶& foo"
(ess-with-enabled-font-lock-keyword 'ess-fl-keyword:operators
(font-lock-ensure)
(should (eq (face-at-point) 'ess-operator-face))))
(etest-deftest ess-r-font-lock-pipe-operator-test ()
:case "a ¶|¶> b"
(ess-with-enabled-font-lock-keyword 'ess-fl-keyword:operators
(font-lock-ensure)
(should (eq (face-at-point) 'ess-operator-face))))
(etest-deftest ess-r-tokens-pipe-operator-test ()
:case "a ¶|> b"
(should (token= "|>"))
:result "a |>¶ b")
(etest-deftest ess-r-raw-strings-test ()
:case "
r¶\"(foo\"bar))¶\"
r¶\"(foo}\"bar))¶\"
r¶\"(foo)'bar))¶\"
r¶\"---[foo\"bar]---¶\"
r¶\"---[foo\"bar]--\"baz]---¶\"
r¶'{foo'bar}¶'
r¶\"---{foobar}-\\--\"
"
(should (equal (syntax-after (point))
(string-to-syntax "|")))
:case "
r\"¶(foo\"¶bar))¶\"
r\"¶(foo}\"¶bar))¶\"
r\"¶(foo)'¶bar))¶\"
r\"¶---[foo\"¶bar]---¶\"
r\"¶---[foo\"¶bar]--\"¶baz]---¶\"
r'¶{foo'¶bar}¶'
r\"¶---{foobar}¶-\\--\"¶
"
(should (ess-inside-string-p))
:case "
¶r\"(foo\"bar))\"¶,
¶r\"(foo}\"bar))\"¶,
¶r\"(foo)'bar))\"¶,
¶r\"---[foo\"bar]---\"¶,
¶r\"---[foo\"bar]--\"baz]---\"¶,
¶r'{foo'bar}'¶,
¶r\"---{foobar}-\\--\"
"
(should (not (ess-inside-string-p)))
:case "r\"(foor\"()\"ba¶r))\""
(should (not (ess-inside-string-p)))
:case "
r\"(foor¶'()¶'bar))\"
# r¶\"{foo}¶\"
"
(should (not (equal (syntax-after (point))
(string-to-syntax "|")))))
;; Local Variables:
;; etest-local-config: etest-r-config
;; End:
|