Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
100 changes: 84 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,103 @@ name: CI

on:
push:
branches: [ master ]
pull_request:
schedule: [cron: "40 1 * * *"]
branches: [ master ]

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings --cfg docsrs

jobs:
test:
name: Rust ${{matrix.rust}}
get-package-info:
runs-on: ubuntu-latest
outputs:
msrv: ${{ steps.msrv.outputs.metadata }}
name: ${{ steps.name.outputs.metadata }}
version: ${{ steps.version.outputs.metadata }}
steps:
- uses: actions/checkout@v5
- name: Get MSRV
id: msrv
uses: nicolaiunrein/[email protected]
with:
subcommand: 'package.rust_version'
- name: Get package name
id: name
uses: nicolaiunrein/[email protected]
with:
subcommand: 'package.name'
- name: Get package version
id: version
uses: nicolaiunrein/[email protected]
with:
subcommand: 'package.version'

build_test:
needs: get-package-info
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable]
os: [ ubuntu-latest, windows-latest ]
rust:
- ${{ needs.get-package-info.outputs.msrv }}
- stable
- beta
- nightly
exclude:
# excludes MSRV on Windows due to linker issues
- os: windows-latest
rust: ${{ needs.get-package-info.outputs.msrv }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v5
- name: Install toolchain
if: matrix.rust != needs.get-package-info.outputs.msrv
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
profile: minimal
override: true
- run: cargo build --features bench
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Install MSRV toolchain
if: matrix.rust == needs.get-package-info.outputs.msrv
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.get-package-info.outputs.msrv }}
- name: Remove dev-dependencies for MSRV (very dirty hack)
if: matrix.rust == needs.get-package-info.outputs.msrv
shell: pwsh
run: |
(Get-Content Cargo.toml) -replace '^\[dev-dependencies\].*?(\n\[|$)', '[placeholder]' | Set-Content Cargo.toml
- name: Build
run: cargo build --verbose
- name: Run tests with all features
run: cargo test --all-features --verbose
if: matrix.rust == 'nightly'
- run: cargo test --features bench
- name: Run tests without features
run: cargo test --no-default-features --verbose
- name: Package
run: cargo package --allow-dirty
- name: Test package
working-directory: target/package/${{ needs.get-package-info.outputs.name }}-${{ needs.get-package-info.outputs.version }}/
run: cargo test --verbose
- name: Test package without features
working-directory: target/package/${{ needs.get-package-info.outputs.name }}-${{ needs.get-package-info.outputs.version }}/
run: cargo test --no-default-features --verbose
- name: Run benchmarks
run: cargo bench --features bench --verbose
if: matrix.rust == 'nightly'
- run: cargo bench --features bench
- name: Build docs
run: cargo doc --all-features --verbose
if: matrix.rust == 'nightly'
- run: cargo build

tables:
name: Verify tables
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- name: Regenerate tables
run: ./scripts/unicode.py && rustfmt tables.rs
- name: Verify regenerated files
run: ./scripts/unicode.py && rustfmt tables.rs && diff tables.rs src/tables.rs
run: diff tables.rs src/tables.rs
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

name = "unicode-xid"
version = "0.2.6"
authors = ["erick.tryzelaar <[email protected]>",
"kwantam <[email protected]>",
"Manish Goregaokar <[email protected]>"
]
authors = [
"erick.tryzelaar <[email protected]>",
"kwantam <[email protected]>",
"Manish Goregaokar <[email protected]>",
]

homepage = "https://github.com/unicode-rs/unicode-xid"
repository = "https://github.com/unicode-rs/unicode-xid"
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
//! ```rust
//! use unicode_xid::UnicodeXID;
//!
//! fn main() {
//! assert_eq!(UnicodeXID::is_xid_start('a'), true); // 'a' is a valid start of an identifier
//! assert_eq!(UnicodeXID::is_xid_start('△'), false); // '△' is a NOT valid start of an identifier
//! }
//! assert_eq!(UnicodeXID::is_xid_start('a'), true); // 'a' is a valid start of an identifier
//! assert_eq!(UnicodeXID::is_xid_start('△'), false); // '△' is a NOT valid start of an identifier
//! ```
//!
//! # features
Expand All @@ -33,7 +31,7 @@
html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png"
)]
#![no_std]
#![cfg_attr(feature = "bench", feature(test, unicode_internals))]
#![cfg_attr(feature = "bench", feature(test))]

#[cfg(test)]
#[macro_use]
Expand Down
16 changes: 11 additions & 5 deletions tests/exhaustive_tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
extern crate unicode_xid;

use unicode_xid::UnicodeXID;
/// A `char` in Rust is a Unicode Scalar Value
///
/// See: http://www.unicode.org/glossary/#unicode_scalar_value
fn all_valid_chars() -> impl Iterator<Item = char> {
(0u32..=0xD7FF).chain(0xE000u32..=0x10FFFF).map(|u| {
core::convert::TryFrom::try_from(u)
.expect("The selected range should be infallible if the docs match impl")
})
fn all_valid_chars() -> Vec<char> {
(0u32..0xD7FF)
.chain(Some(0xD7FF))
.chain(0xE000u32..0x10FFFF)
.chain(Some(0x10FFFF))
.map(|u| {
std::char::from_u32(u)
.expect("The selected range should be infallible if the docs match impl")
})
.collect()
}

#[test]
Expand Down
Loading