Skip to content

Commit

Permalink
clippyのエラーに一部対応した
Browse files Browse the repository at this point in the history
  • Loading branch information
hidekuno committed Nov 10, 2023
1 parent 9f421d9 commit 4cea33e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ffilisp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub extern "C" fn do_scheme(program: *const c_char) -> *mut c_char {
let env = &ENV;

let program = unsafe { CStr::from_ptr(program).to_str().unwrap() };
let value = match elisp::lisp::do_core_logic(program, &env) {
let value = match elisp::lisp::do_core_logic(program, env) {
Ok(v) => v.to_string(),
Err(e) => e.get_msg(),
};
Expand Down
22 changes: 13 additions & 9 deletions ffilisp/test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import unittest
import ctypes
import sys
import unittest

rust = ctypes.cdll.LoadLibrary("target/release/libffilisp.so")

def do_scheme(ex):
p = ctypes.create_string_buffer(ex.encode('utf-8'))
p = ctypes.create_string_buffer(ex.encode("utf-8"))
r = rust.do_scheme(p)
return ctypes.c_char_p(r).value.decode('utf-8')
return ctypes.c_char_p(r).value.decode("utf-8")


class TestMethods(unittest.TestCase):
# the testing framework will automatically call for every single test
Expand All @@ -18,17 +20,19 @@ def tearDown(self):
pass

def test_calc(self):
self.assertEqual("6",do_scheme("(+ 1 2 3)"))
self.assertEqual("6", do_scheme("(+ 1 2 3)"))

def test_define(self):
self.assertEqual("a",do_scheme("(define a 100)"))
self.assertEqual("2000",do_scheme("(* a 20)"))
self.assertEqual("a", do_scheme("(define a 100)"))
self.assertEqual("2000", do_scheme("(* a 20)"))

def test_lambda(self):
self.assertEqual("test",do_scheme("(define test (lambda (a b)(+ a b)))"))
self.assertEqual("30",do_scheme("(test 10 20)"))
self.assertEqual("test", do_scheme(
"(define test (lambda (a b)(+ a b)))"))
self.assertEqual("30", do_scheme("(test 10 20)"))


if __name__ == '__main__':
if __name__ == "__main__":
try:
unittest.main()
except Exception as e:
Expand Down
5 changes: 2 additions & 3 deletions weblisp/samples/examples/index.cgi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/python
import sys
from os import environ

print("Content-Type: text/plain")
print("Status: 200")
print("")

for (k,v) in environ.items():
print("%s=%s" % (k, v))
for k, v in environ.items():
print("%s=%s" % (k, v))
3 changes: 1 addition & 2 deletions weblisp/samples/examples/post.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ print("")

line = sys.stdin.readline()
print(line.rstrip("\n"))
print(environ['QUERY_STRING'])

print(environ["QUERY_STRING"])
5 changes: 2 additions & 3 deletions weblisp/samples/examples/redirect.cgi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/python
import sys
from os import environ

print("Content-Type: text/plain")
print("Status: 301")
print("Location: https://www.yahoo.co.jp/")
print("")

for (k,v) in environ.items():
print("%s=%s" % (k, v))
for k, v in environ.items():
print("%s=%s" % (k, v))
5 changes: 2 additions & 3 deletions weblisp/samples/examples/redirect302.cgi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/python
import sys
from os import environ

print("Content-Type: text/plain")
print("Status: 302")
print("Location: https://www.yahoo.co.jp/")
print("")

for (k,v) in environ.items():
print("%s=%s" % (k, v))
for k, v in environ.items():
print("%s=%s" % (k, v))

0 comments on commit 4cea33e

Please sign in to comment.