Skip to content

Fix for latest nightly #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn upvalueindex(n: i32) -> i32 {
raw::lua_upvalueindex(n as c_int) as i32
}

include!(concat!(env!("OUT_DIR"), "/config.rs"))
include!(concat!(env!("OUT_DIR"), "/config.rs"));

#[allow(missing_docs)]
pub mod raw;
Expand Down Expand Up @@ -2900,7 +2900,7 @@ impl<'l> RawState<'l> {
}
lstv.push(ptr::null());
let i = aux::raw::luaL_checkoption(self.L, narg as c_int, defp, lstv.as_ptr()) as uint;
lst[i].ref1()
& lst[i].1
}

pub unsafe fn ref_(&mut self, t: i32) -> i32 {
Expand Down
25 changes: 15 additions & 10 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use Type;
use raw;

use libc;
use std::task;
use std::thread::Thread;
use std::any::AnyRefExt;
use std::any::Any;
use std::sync::Arc;

#[test]
fn test_state_init() {
Expand All @@ -22,10 +24,10 @@ fn test_error() {

#[test]
fn test_errorstr() {
let res = task::try::<()>(proc() {
let res : Result<(), Box<Any + Send>> = Thread::spawn(move || {
let mut s = State::new();
s.errorstr("some err");
});
}).join();
let err = res.unwrap_err();
let expected = "unprotected error in call to Lua API (some err)";
let s = err.downcast_ref::<String>();
Expand Down Expand Up @@ -93,16 +95,19 @@ fn test_checkoption() {
}
assert_eq!(*s.checkoption(1, Some("three"), &lst), CheckOptionEnum::Three);

let res = task::try(proc() {
let lst_arc1 = Arc::new(lst);
let lst_arc2 = lst_arc1.clone();

let res = Thread::spawn(move || {
let mut s = State::new();
s.checkoption(1, None, &lst);
});
s.checkoption(1, None, &*lst_arc1);
}).join();
assert!(res.is_err(), "expected error from checkoption");

let res = task::try(proc() {
let res = Thread::spawn(move || {
let mut s = State::new();
s.checkoption(1, Some("four"), &lst);
});
s.checkoption(1, Some("four"), &*lst_arc2);
}).join();
assert!(res.is_err(), "expected error from checkoption");
}

Expand Down