Back

to-sym (clj)

(source)

function

(to-sym x)
Converts x to a non-namespaced symbol, throwing if x is namespaced

Examples

migratus
(ns migratus.test.migration.edn
  (:require [clojure.java.io :as io]
            [clojure.test :refer :all]
            [migratus.core :as core]
            [migratus.migration.edn :refer :all]
            migratus.mock
            [migratus.protocols :as proto]
            [migratus.utils :as utils])
  (:import java.io.File))

(deftest test-to-sym
  (are [x y] (= y (to-sym x))
    nil nil
    "aaa" 'aaa
    'aaa 'aaa
    :aaa 'aaa)
  (are [x] (thrown-with-msg?
            IllegalArgumentException
            #"Namespaced symbol not allowed"
            (to-sym x))
    "aaa/bbb"
    'aaa/bbb
    :aaa/bbb
    'a.b.c/def
    :a.b.c/def))