mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 00:51:56 +00:00 
			
		
		
		
	Add Clojure syntax test.
This commit is contained in:
		
				
					committed by
					
						
						David Peter
					
				
			
			
				
	
			
			
			
						parent
						
							f10c8ce25e
						
					
				
				
					commit
					46004001cb
				
			
							
								
								
									
										58
									
								
								tests/syntax-tests/highlighted/Clojure/test.clj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								tests/syntax-tests/highlighted/Clojure/test.clj
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
			
		||||
[38;2;248;248;242m([0m[38;2;248;248;242mns[0m[38;2;248;248;242m clojure-sample.core[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;190;132;255m:[0m[38;2;190;132;255mgen-class[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;248;248;242mrequire[0m[38;2;248;248;242m [0m[38;2;249;38;114m'[0m[38;2;248;248;242m[[0m[38;2;248;248;242mclj-time.core [0m[38;2;190;132;255m:[0m[38;2;190;132;255mas[0m[38;2;248;248;242m t[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;248;248;242mrequire[0m[38;2;248;248;242m [0m[38;2;249;38;114m'[0m[38;2;248;248;242m[[0m[38;2;248;248;242mclj-time.format [0m[38;2;190;132;255m:[0m[38;2;190;132;255mas[0m[38;2;248;248;242m f[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Product record[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[3;38;2;102;217;239mdefrecord[0m[38;2;248;248;242m [0m[38;2;166;226;46mProduct[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242mid name available price[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Positional constructor[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mproduct1[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m->Product[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mT-Shirt 1[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m[38;2;248;248;242m [0m[38;2;190;132;255m15[0m[38;2;190;132;255m.[0m[38;2;190;132;255m00[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Map constructor[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mproduct2[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mmap->Product[0m
 | 
			
		||||
[38;2;248;248;242m                 [0m[38;2;248;248;242m{[0m[38;2;190;132;255m:[0m[38;2;190;132;255mid[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m2[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                  [0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mT-Shirt 2[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                  [0m[38;2;190;132;255m:[0m[38;2;190;132;255mavailable[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m
 | 
			
		||||
[38;2;248;248;242m                  [0m[38;2;190;132;255m:[0m[38;2;190;132;255mprice[0m[38;2;248;248;242m [0m[38;2;190;132;255m20[0m[38;2;190;132;255m.[0m[38;2;190;132;255m00[0m[38;2;248;248;242m}[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Nested[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mproduct3[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;190;132;255m:[0m[38;2;190;132;255mid[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m1[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                 [0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mProduct 1[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                 [0m[38;2;190;132;255m:[0m[38;2;190;132;255mavailable[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m
 | 
			
		||||
[38;2;248;248;242m                 [0m[38;2;190;132;255m:[0m[38;2;190;132;255msellers[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m{[0m[38;2;190;132;255m:[0m[38;2;190;132;255mid[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m1[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSeller 1[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;190;132;255m:[0m[38;2;190;132;255mstock[0m[38;2;248;248;242m [0m[38;2;190;132;255m3[0m[38;2;248;248;242m}[0m[38;2;117;113;94m,[0m
 | 
			
		||||
[38;2;248;248;242m                           [0m[38;2;248;248;242m{[0m[38;2;190;132;255m:[0m[38;2;190;132;255mid[0m[38;2;248;248;242m [0m[38;2;190;132;255m2[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSeller 2[0m[38;2;230;219;116m"[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;190;132;255m:[0m[38;2;190;132;255mstock[0m[38;2;248;248;242m [0m[38;2;190;132;255m5[0m[38;2;248;248;242m}[0m[38;2;248;248;242m][0m[38;2;248;248;242m}[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Set[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mcategories[0m[38;2;248;248;242m [0m[38;2;248;248;242m#{[0m[38;2;230;219;116m"[0m[38;2;230;219;116mshirts[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mshoes[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mbelts[0m[38;2;230;219;116m"[0m[38;2;248;248;242m}[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m List[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mwishlist[0m[38;2;248;248;242m [0m[38;2;249;38;114m'[0m[38;2;248;248;242m([0m[38;2;190;132;255m1[0m[38;2;248;248;242m [0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;117;113;94m;;[0m[38;2;117;113;94m Recursion[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdefn[0m[38;2;248;248;242m [0m[38;2;166;226;46mfactorial[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242mvalue[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mcond[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;248;248;242m([0m[38;2;248;248;242m<=[0m[38;2;248;248;242m value [0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m
 | 
			
		||||
[38;2;248;248;242m                            [0m[38;2;190;132;255m:[0m[38;2;190;132;255melse[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m*[0m[38;2;248;248;242m value [0m[38;2;248;248;242m([0m[38;2;248;248;242mfactorial[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m-[0m[38;2;248;248;242m value [0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mbasic-formatter[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mf/formatter[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mYYYY-MM-dd hh:mm:ss[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdefn[0m[38;2;248;248;242m [0m[38;2;166;226;46mnow[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mf/unparse[0m[38;2;248;248;242m basic-formatter [0m[38;2;248;248;242m([0m[38;2;248;248;242mt/now[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdefn[0m[38;2;248;248;242m [0m[38;2;166;226;46mlog[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mnow[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mNo message[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242m[[0m[38;2;248;248;242mmessage[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mnow[0m[38;2;248;248;242m)[0m[38;2;248;248;242m  message[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
[38;2;248;248;242m  [0m[38;2;248;248;242m([0m[38;2;249;38;114mdefn[0m[38;2;248;248;242m [0m[38;2;166;226;46m-main[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m[[0m[38;2;248;248;242m& args[0m[38;2;248;248;242m][0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m:[0m[38;2;190;132;255mid[0m[38;2;248;248;242m product1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m product2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m:[0m[38;2;190;132;255mname[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mget[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m:[0m[38;2;190;132;255msellers[0m[38;2;248;248;242m product3[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mfirst[0m[38;2;248;248;242m categories[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m wishlist[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242mfactorial[0m[38;2;248;248;242m [0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mlog[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m    [0m[38;2;248;248;242m([0m[38;2;248;248;242mlog[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mMessage[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
 | 
			
		||||
[38;2;248;248;242m  [0m
 | 
			
		||||
							
								
								
									
										58
									
								
								tests/syntax-tests/source/Clojure/test.clj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								tests/syntax-tests/source/Clojure/test.clj
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
			
		||||
(ns clojure-sample.core
 | 
			
		||||
    (:gen-class))
 | 
			
		||||
  
 | 
			
		||||
  (require '[clj-time.core :as t])
 | 
			
		||||
  (require '[clj-time.format :as f])
 | 
			
		||||
  
 | 
			
		||||
  ;; Product record
 | 
			
		||||
  (defrecord Product [id name available price])
 | 
			
		||||
  
 | 
			
		||||
  ;; Positional constructor
 | 
			
		||||
  (def product1 (->Product "1" "T-Shirt 1" true 15.00))
 | 
			
		||||
  
 | 
			
		||||
  ;; Map constructor
 | 
			
		||||
  (def product2 (map->Product
 | 
			
		||||
                 {:id "2"
 | 
			
		||||
                  :name "T-Shirt 2"
 | 
			
		||||
                  :available true
 | 
			
		||||
                  :price 20.00}))
 | 
			
		||||
  
 | 
			
		||||
  ;; Nested
 | 
			
		||||
  (def product3 {:id "1"
 | 
			
		||||
                 :name "Product 1"
 | 
			
		||||
                 :available true
 | 
			
		||||
                 :sellers [{:id "1"
 | 
			
		||||
                            :name "Seller 1"
 | 
			
		||||
                            :stock 3},
 | 
			
		||||
                           {:id 2
 | 
			
		||||
                            :name "Seller 2"
 | 
			
		||||
                            :stock 5}]})
 | 
			
		||||
  
 | 
			
		||||
  ;; Set
 | 
			
		||||
  (def categories #{"shirts" "shoes" "belts"})
 | 
			
		||||
  
 | 
			
		||||
  ;; List
 | 
			
		||||
  (def wishlist '(1 2))
 | 
			
		||||
  
 | 
			
		||||
  ;; Recursion
 | 
			
		||||
  (defn factorial [value] (cond
 | 
			
		||||
                            (<= value 1) 1
 | 
			
		||||
                            :else (* value (factorial (- value 1)))))
 | 
			
		||||
  
 | 
			
		||||
  (def basic-formatter (f/formatter "YYYY-MM-dd hh:mm:ss"))
 | 
			
		||||
  (defn now [] (f/unparse basic-formatter (t/now)))
 | 
			
		||||
  (defn log
 | 
			
		||||
    ([] (println (now) "No message"))
 | 
			
		||||
    ([message] (println (now)  message)))
 | 
			
		||||
  
 | 
			
		||||
  (defn -main
 | 
			
		||||
    [& args]
 | 
			
		||||
    (println (:id product1))
 | 
			
		||||
    (println (:name product2))
 | 
			
		||||
    (println (:name (get (:sellers product3) 0)))
 | 
			
		||||
    (println (first categories))
 | 
			
		||||
    (println wishlist)
 | 
			
		||||
    (println (factorial 5))
 | 
			
		||||
    (log)
 | 
			
		||||
    (log "Message"))
 | 
			
		||||
  
 | 
			
		||||
		Reference in New Issue
	
	Block a user