mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	samples: add Terra samples
source: https://github.com/zdevito/terra/tree/master/tests
This commit is contained in:
		
							
								
								
									
										47
									
								
								samples/Terra/coverage.t
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								samples/Terra/coverage.t
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| function failit(match,fn) | ||||
| 	local success,msg = pcall(fn) | ||||
| 	if success then | ||||
| 		error("failed to fail.",2) | ||||
| 	elseif not string.match(msg,match) then | ||||
| 		error("failed wrong: "..msg,2) | ||||
| 	end | ||||
| end | ||||
| local test = require("test") | ||||
| local erd = "Errors reported during" | ||||
|  | ||||
| local terra f1() | ||||
| 	return test | ||||
| end | ||||
|  | ||||
| failit(erd,function() | ||||
| f1:compile() | ||||
| end) | ||||
| failit("referencing a function which failed to compile",function() | ||||
| f1:compile() | ||||
| end) | ||||
| failit(erd,function() | ||||
| 	local terra foo() | ||||
| 		f1() | ||||
| 	end | ||||
| 	foo() | ||||
| end) | ||||
|  | ||||
|  | ||||
| local struct A { | ||||
| 	a : int | ||||
| } | ||||
|  | ||||
| A.metamethods.__getentries = function(self) | ||||
| 	error("I AM BAD") | ||||
| end | ||||
|  | ||||
| failit(erd,function() | ||||
| 	A:complete() | ||||
| end) | ||||
|  | ||||
| failit(erd,function() | ||||
| 	local terra foo() | ||||
| 		var a : A | ||||
| 	end | ||||
| 	foo() | ||||
| end) | ||||
		Reference in New Issue
	
	Block a user