Mercurial Hosting > luan
diff src/luan/modules/http/Http_test.luan @ 1520:d9a5405a3102
try statement
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 21 Jun 2020 18:14:13 -0600 |
parents | b3c4fcf29a53 |
children | b82767112d8e |
line wrap: on
line diff
--- a/src/luan/modules/http/Http_test.luan Fri Jun 19 20:10:47 2020 -0600 +++ b/src/luan/modules/http/Http_test.luan Sun Jun 21 18:14:13 2020 -0600 @@ -1,7 +1,6 @@ local Luan = require "luan:Luan.luan" local error = Luan.error local set_metatable = Luan.set_metatable or error() -local try = Luan.try or error() local Package = require "luan:Package.luan" local Io = require "luan:Io.luan" local String = require "luan:String.luan" @@ -20,30 +19,24 @@ path = path .. Http_test.welcome_file end local old_out = Io.stdout - try { - function() - local mod = Package.load("site:"..path..".luan") or error(path.." not found") - mod() - Http_test.text_writer.close() - end - finally = function() - Io.stdout = old_out - end - } + try + local mod = Package.load("site:"..path..".luan") or error(path.." not found") + mod() + Http_test.text_writer.close() + finally + Io.stdout = old_out + end return Http_test.result.read_text() end function Http_test.run_page(page_fn) local old_out = Io.stdout - try { - function() - page_fn() - Http_test.text_writer.close() - end - finally = function() - Io.stdout = old_out - end - } + try + page_fn() + Http_test.text_writer.close() + finally + Io.stdout = old_out + end return Http_test.result.read_text() end