Skip to content
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

Add an `Unserializable` type to utils #9379

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

util: Add unit test for `Unserializable`

  • Loading branch information
emilio committed Jan 19, 2016
commit 5677d507551a987680bf8b0f7b3a8bfb2b1b6393

Some generated files are not rendered by default. Learn more.

@@ -17,6 +17,11 @@ path = "../../../components/plugins"

[dependencies]
app_units = {version = "0.1", features = ["plugins"]}
libc = "0.2"
euclid = {version = "0.4", features = ["plugins"]}
libc = "0.2"
serde = "0.6"
serde_macros = "0.6"

[dependencies.ipc-channel]
git = "https://github.com/servo/ipc-channel"

@@ -0,0 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use ipc_channel::ipc;
use std::sync::mpsc::channel;
use util::ipc::Unserializable;

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
enum Dummy {
Serializable(i32),
Unserializable(Unserializable<i32>),
}

#[test]
fn test_serializable() {
let (tx, rx) = ipc::channel().unwrap();
tx.send(Dummy::Serializable(4)).unwrap();
assert_eq!(rx.recv().unwrap(), Dummy::Serializable(4));
}

#[test]
fn test_unserializable_in_process() {
let (tx, rx) = channel();
tx.send(Dummy::Unserializable(Unserializable::new(4))).unwrap();
assert_eq!(rx.recv().unwrap(), Dummy::Unserializable(Unserializable::new(4)));
}

#[test]
#[should_panic]
fn test_unserializable_over_ipc() {
let (tx, _rx) = ipc::channel().unwrap();
tx.send(Dummy::Unserializable(Unserializable::new(4))).unwrap();
}
@@ -5,11 +5,15 @@
#![cfg_attr(test, feature(plugin, custom_derive, heap_api))]
#![cfg_attr(test, plugin(plugins))]
#![feature(alloc)]
#![feature(plugin)]
#![plugin(serde_macros)]

extern crate alloc;
extern crate app_units;
extern crate euclid;
extern crate ipc_channel;
extern crate libc;
extern crate serde;
extern crate util;

#[cfg(test)] mod cache;
@@ -19,3 +23,4 @@ extern crate util;
#[cfg(test)] mod mem;
#[cfg(test)] mod str;
#[cfg(test)] mod opts;
#[cfg(test)] mod ipc;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.