mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Add an SML syntax test file.
This commit is contained in:
		
				
					committed by
					
						 David Peter
						David Peter
					
				
			
			
				
	
			
			
			
						parent
						
							62397dbd0b
						
					
				
				
					commit
					88ea21b276
				
			
							
								
								
									
										47
									
								
								tests/syntax-tests/highlighted/SML/sample.sml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								tests/syntax-tests/highlighted/SML/sample.sml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m x = [0m[38;2;190;132;255m0[0m | ||||
|  | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m hello = [0m[38;2;230;219;116m"hello world"[0m | ||||
|  | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m id = [0m[38;2;249;38;114mfn[0m[38;2;248;248;242m x [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m x[0m | ||||
|  | ||||
| [38;2;249;38;114mfun[0m[38;2;248;248;242m id' x = x[0m | ||||
|  | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;190;132;255m()[0m[38;2;248;248;242m = [0m[38;2;249;38;114mprint[0m[38;2;248;248;242m [0m[38;2;230;219;116m"hello world\n"[0m | ||||
|  | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m _ = [0m[38;2;249;38;114mlet[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mval[0m[38;2;248;248;242m hello = [0m[38;2;230;219;116m"hello"[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mval[0m[38;2;248;248;242m world = [0m[38;2;230;219;116m"world"[0m | ||||
| [38;2;249;38;114min[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mprint[0m[38;2;248;248;242m (hello ^ [0m[38;2;230;219;116m" "[0m[38;2;248;248;242m ^ world ^ [0m[38;2;230;219;116m"\n"[0m[38;2;248;248;242m)[0m | ||||
| [38;2;249;38;114mend[0m | ||||
|  | ||||
| [38;2;249;38;114mfun[0m[38;2;248;248;242m isZero n =[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mif[0m[38;2;248;248;242m n = [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;249;38;114mthen[0m[38;2;248;248;242m [0m[38;2;249;38;114mtrue[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114melse[0m[38;2;248;248;242m [0m[38;2;249;38;114mfalse[0m | ||||
|  | ||||
| [38;2;249;38;114mfun[0m[38;2;248;248;242m isTrue b =[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mcase[0m[38;2;248;248;242m b [0m[38;2;249;38;114mof[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mtrue[0m[38;2;248;248;242m [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m [0m[38;2;249;38;114mtrue[0m | ||||
| [38;2;248;248;242m  | [0m[38;2;249;38;114mfalse[0m[38;2;248;248;242m [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m [0m[38;2;249;38;114mfalse[0m | ||||
|  | ||||
| [38;2;249;38;114mexception[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBad_value[0m[38;2;248;248;242m [0m[38;2;249;38;114mof[0m[38;2;248;248;242m [0m[38;2;249;38;114mstring[0m | ||||
|  | ||||
| [38;2;249;38;114mfun[0m[38;2;248;248;242m isTrue' b =[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mcase[0m[38;2;248;248;242m b [0m[38;2;249;38;114mof[0m | ||||
| [38;2;248;248;242m    [0m[38;2;249;38;114mtrue[0m[38;2;248;248;242m [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m [0m[38;2;249;38;114mtrue[0m | ||||
| [38;2;248;248;242m  | _    [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m [0m[38;2;249;38;114mraise[0m[38;2;248;248;242m ([0m[3;38;2;166;226;46mBad_value[0m[38;2;248;248;242m [0m[38;2;230;219;116m"value is not true!"[0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [38;2;249;38;114mval[0m[38;2;248;248;242m alwaysTrue =[0m | ||||
| [38;2;248;248;242m  isTrue' [0m[38;2;249;38;114mfalse[0m[38;2;248;248;242m [0m[38;2;249;38;114mhandle[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBad_value[0m[38;2;248;248;242m _ [0m[38;2;190;132;255m=>[0m[38;2;248;248;242m [0m[38;2;249;38;114mtrue[0m | ||||
|  | ||||
| [38;2;249;38;114mdatatype[0m[38;2;248;248;242m myBool = [0m[3;38;2;166;226;46mTrue[0m[38;2;248;248;242m | [0m[3;38;2;166;226;46mFalse[0m | ||||
|  | ||||
| [38;2;249;38;114mdatatype[0m[38;2;248;248;242m shape = [0m[3;38;2;166;226;46mSquare[0m[38;2;248;248;242m [0m[38;2;249;38;114mof[0m[38;2;248;248;242m [0m[38;2;249;38;114mreal[0m[38;2;248;248;242m | [0m[3;38;2;166;226;46mCircle[0m[38;2;248;248;242m [0m[38;2;249;38;114mof[0m[38;2;248;248;242m [0m[38;2;249;38;114mreal[0m[38;2;248;248;242m | [0m[3;38;2;166;226;46mPoint[0m | ||||
|  | ||||
| [38;2;249;38;114msignature[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mFOO[0m[38;2;248;248;242m = [0m[38;2;249;38;114msig[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mval[0m[38;2;248;248;242m foo : 'a [0m[38;2;190;132;255m->[0m[38;2;248;248;242m 'a[0m | ||||
| [38;2;249;38;114mend[0m | ||||
|  | ||||
| [38;2;249;38;114mstructure[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mFoo[0m[38;2;248;248;242m [0m[38;2;190;132;255m:>[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mFOO[0m[38;2;248;248;242m = [0m[38;2;249;38;114mstruct[0m | ||||
| [38;2;248;248;242m  [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m foo x = x[0m | ||||
| [38;2;249;38;114mend[0m | ||||
							
								
								
									
										47
									
								
								tests/syntax-tests/source/SML/sample.sml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								tests/syntax-tests/source/SML/sample.sml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| val x = 0 | ||||
|  | ||||
| val hello = "hello world" | ||||
|  | ||||
| val id = fn x => x | ||||
|  | ||||
| fun id' x = x | ||||
|  | ||||
| val () = print "hello world\n" | ||||
|  | ||||
| val _ = let | ||||
|   val hello = "hello" | ||||
|   val world = "world" | ||||
| in | ||||
|   print (hello ^ " " ^ world ^ "\n") | ||||
| end | ||||
|  | ||||
| fun isZero n = | ||||
|   if n = 0 then true | ||||
|   else false | ||||
|  | ||||
| fun isTrue b = | ||||
|   case b of | ||||
|     true => true | ||||
|   | false => false | ||||
|  | ||||
| exception Bad_value of string | ||||
|  | ||||
| fun isTrue' b = | ||||
|   case b of | ||||
|     true => true | ||||
|   | _    => raise (Bad_value "value is not true!") | ||||
|  | ||||
| val alwaysTrue = | ||||
|   isTrue' false handle Bad_value _ => true | ||||
|  | ||||
| datatype myBool = True | False | ||||
|  | ||||
| datatype shape = Square of real | Circle of real | Point | ||||
|  | ||||
| signature FOO = sig | ||||
|   val foo : 'a -> 'a | ||||
| end | ||||
|  | ||||
| structure Foo :> FOO = struct | ||||
|   fun foo x = x | ||||
| end | ||||
		Reference in New Issue
	
	Block a user