added Cargo support and updated .travis.yml; language changes: ToStr -> ToString.

This commit is contained in:
Kang Seonghoon 2014-07-12 23:41:22 +09:00
parent 75d90a56fa
commit 11b2a10247
9 changed files with 38 additions and 77 deletions

14
.gitignore vendored
View File

@ -1,14 +1,2 @@
*~
*#
*.o
*.so
*.dylib
*.dSYM
*.dll
*.rlib
*.dummy
*.exe
build
Makefile
*-test
doc
target

View File

@ -1,18 +1,20 @@
env:
global:
- secure: i8Ijk6g4/26e3e7+r2OeGAPSP8G8O9P50JibW1omJ0j0ixXhyhPoY2bch3CGhnOu44dI5O31IIbjJJ+iEMp29xQBvkv9YpxAI+hIzOP+XAH6GCYxUDiBVcDoWrXTj+wU6/veuvjLCunu4eRHlskrgJbZXhUVODYzJuLgsN8Ou0w=
#before_install:
before_install:
# - yes | sudo add-apt-repository ppa:hansjorg/rust
# - sudo apt-get update
install:
- curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
- tar xfz rust-nightly-x86_64-unknown-linux-gnu.tar.gz
- (cd rust-nightly-x86_64-unknown-linux-gnu/ && sudo ./install.sh)
# - sudo apt-get install rust-nightly
- curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
- curl -O http://static.rust-lang.org/cargo-dist/cargo-nightly-linux.tar.gz
- tar xfz rust-nightly-x86_64-unknown-linux-gnu.tar.gz
- (cd rust-nightly-x86_64-unknown-linux-gnu/ && sudo ./install.sh --prefix=/usr)
- tar xfz cargo-nightly-linux.tar.gz
- sudo cp -R cargo-nightly/* /usr
script:
- ./configure
- make check RUSTFLAGS=
- make doc
- cargo build
- cargo test
- rustdoc src/chrono/lib.rs
branches:
only:
- master

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "chrono"
version = "0.1.0"
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
[[lib]]
name = "chrono"
path = "src/chrono/lib.rs"

View File

@ -1,33 +0,0 @@
VPATH=%VPATH%
CC ?= gcc
CXX ?= g++
CXXFLAGS ?=
AR ?= ar
RUSTC ?= rustc
RUSTDOC ?= rustdoc
RUSTFLAGS ?= -O
LIB_RS = src/chrono/lib.rs
RUST_SRC = $(shell find $(VPATH)/src/chrono -type f -name '*.rs')
.PHONY: all
all: libchrono.dummy
libchrono.dummy: $(LIB_RS) $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< --out-dir .
touch $@
chrono-test: $(LIB_RS) $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< -o $@ --test
check: chrono-test
./chrono-test
doc: $(LIB_RS) $(RUST_SRC)
$(RUSTDOC) $(LIB_RS)
.PHONY: clean
clean:
rm -f *.o *.a *.so *.dylib *.rlib *.dll *.dummy *.exe *-test

4
configure vendored
View File

@ -1,4 +0,0 @@
#!/bin/bash
SRCDIR="$(cd $(dirname $0) && pwd)"
sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.in > Makefile

View File

@ -701,10 +701,10 @@ mod tests {
#[test]
fn test_date_fmt() {
assert_eq!(DateZ::from_ymd(2012, 3, 4).unwrap().to_str(), "2012-03-04".to_string());
assert_eq!(DateZ::from_ymd(0, 3, 4).unwrap().to_str(), "0000-03-04".to_string());
assert_eq!(DateZ::from_ymd(-307, 3, 4).unwrap().to_str(), "-0307-03-04".to_string());
assert_eq!(DateZ::from_ymd(12345, 3, 4).unwrap().to_str(), "+12345-03-04".to_string());
assert_eq!(DateZ::from_ymd(2012, 3, 4).unwrap().to_string(), "2012-03-04".to_string());
assert_eq!(DateZ::from_ymd(0, 3, 4).unwrap().to_string(), "0000-03-04".to_string());
assert_eq!(DateZ::from_ymd(-307, 3, 4).unwrap().to_string(), "-0307-03-04".to_string());
assert_eq!(DateZ::from_ymd(12345, 3, 4).unwrap().to_string(), "+12345-03-04".to_string());
}
}

View File

@ -399,14 +399,14 @@ mod tests {
#[test]
fn test_duration_fmt() {
assert_eq!(Duration::zero().to_str(), "PT0S".to_string());
assert_eq!(Duration::days(42).to_str(), "P42D".to_string());
assert_eq!(Duration::days(-42).to_str(), "P-42D".to_string());
assert_eq!(Duration::seconds(42).to_str(), "PT42S".to_string());
assert_eq!(Duration::milliseconds(42).to_str(), "PT0,042S".to_string());
assert_eq!(Duration::microseconds(42).to_str(), "PT0,000042S".to_string());
assert_eq!(Duration::nanoseconds(42).to_str(), "PT0,000000042S".to_string());
assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_str(),
assert_eq!(Duration::zero().to_string(), "PT0S".to_string());
assert_eq!(Duration::days(42).to_string(), "P42D".to_string());
assert_eq!(Duration::days(-42).to_string(), "P-42D".to_string());
assert_eq!(Duration::seconds(42).to_string(), "PT42S".to_string());
assert_eq!(Duration::milliseconds(42).to_string(), "PT0,042S".to_string());
assert_eq!(Duration::microseconds(42).to_string(), "PT0,000042S".to_string());
assert_eq!(Duration::nanoseconds(42).to_string(), "PT0,000000042S".to_string());
assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(),
"P7DT6,543S".to_string());
}
}

View File

@ -2,8 +2,6 @@
// Copyright (c) 2014, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
#![crate_id = "chrono#0.1.0"]
#![crate_type = "lib"]
#![comment = "Date and time library for Rust"]
#![license = "MIT"]

View File

@ -258,12 +258,12 @@ mod tests {
#[test]
fn test_time_fmt() {
assert_eq!(hmsm(23, 59, 59, 999).to_str(), "23:59:59,999".to_string());
assert_eq!(hmsm(23, 59, 59, 1_000).to_str(), "23:59:60".to_string());
assert_eq!(hmsm(23, 59, 59, 1_001).to_str(), "23:59:60,001".to_string());
assert_eq!(TimeZ::from_hms_micro(0, 0, 0, 43210).unwrap().to_str(),
assert_eq!(hmsm(23, 59, 59, 999).to_string(), "23:59:59,999".to_string());
assert_eq!(hmsm(23, 59, 59, 1_000).to_string(), "23:59:60".to_string());
assert_eq!(hmsm(23, 59, 59, 1_001).to_string(), "23:59:60,001".to_string());
assert_eq!(TimeZ::from_hms_micro(0, 0, 0, 43210).unwrap().to_string(),
"00:00:00,043210".to_string());
assert_eq!(TimeZ::from_hms_nano(0, 0, 0, 6543210).unwrap().to_str(),
assert_eq!(TimeZ::from_hms_nano(0, 0, 0, 6543210).unwrap().to_string(),
"00:00:00,006543210".to_string());
}
}