Skip to content

Commit

Permalink
Fixed looping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Aug 27, 2024
1 parent 6d04377 commit ed5db39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ check-format: test_clippy test_fmt ## Check the project for clippy and formattin
test_unit:
source test-utils.sh ;\
section "Cargo test" ;\
cargo test --verbose --all --no-fail-fast --all-features --all-targets
cargo test --all --no-fail-fast --all-features --all-targets

test_clippy:
source test-utils.sh ;\
Expand Down
11 changes: 7 additions & 4 deletions crates/gosub_css3/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,11 @@ impl<'stream> Tokenizer<'stream> {
let mut value = String::new();

loop {
let cc = self.current_char();

// TIMP: confirmation needed
// according to css tests `-\\-` should parsed to `--`
if self.current_char() == Ch('\\')
if cc == Ch('\\')
&& !matches!(self.stream.look_ahead(1), Ch(c) if c.is_ascii_hexdigit())
&& !matches!(self.stream.look_ahead(1), Character::StreamEnd)
{
Expand All @@ -802,11 +804,12 @@ impl<'stream> Tokenizer<'stream> {
continue;
}

if !self.is_ident_char(self.current_char().into()) {
if !self.is_ident_char(cc.into()) {
break;
}

value.push(self.next_char().into());
value.push(cc.into());
self.next_char();
}

value
Expand Down Expand Up @@ -911,7 +914,7 @@ impl<'stream> Tokenizer<'stream> {
}

fn current_char(&self) -> Character {
self.stream.look_ahead(0)
self.stream.read()
}

pub fn tell(&self) -> usize {
Expand Down
10 changes: 6 additions & 4 deletions crates/gosub_shared/src/byte_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@ impl Stream for ByteStream {
return StreamEnd;
}

let current_pos = *self.buffer_pos.borrow();
let original_pos = *self.buffer_pos.borrow();

self.next_n(offset);
let ch = self.read();
self.seek(current_pos);

let mut pos = self.buffer_pos.borrow_mut();
*pos = original_pos;

ch
}
Expand Down Expand Up @@ -258,8 +260,8 @@ impl Stream for ByteStream {

/// Seeks to a specific position in the stream
fn seek(&self, offset: usize) {
self.reset_stream();
self.next_n(offset);
let mut pos = self.buffer_pos.borrow_mut();
*pos = offset;
}

/// Retrieves a slice of the buffer
Expand Down
3 changes: 0 additions & 3 deletions crates/gosub_shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//!
//! This crate supplies a lot of shared functionality in the gosub engine.
//!

extern crate core;

pub mod byte_stream;
pub mod timing;
pub mod types;

0 comments on commit ed5db39

Please sign in to comment.