mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-31 19:28:55 +00:00
Merge pull request #7165 from GPotoshin/core_scanner_issue_7135
A fix to the issue #7153 and a test
This commit is contained in:
@@ -377,8 +377,13 @@ scan_number :: proc(s: ^Scanner, ch: rune, seen_dot: bool) -> (rune, rune) {
|
||||
ch, ds = digits(s, ch, base, &invalid)
|
||||
digsep |= ds
|
||||
if ch == '.' && .Scan_Floats in s.flags {
|
||||
prev_s := s^
|
||||
ch = advance(s)
|
||||
seen_dot = true
|
||||
if ch == '.' {
|
||||
s^ = prev_s
|
||||
} else {
|
||||
seen_dot = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
tests/core/text/scanner/test_core_text_scanner.odin
Normal file
18
tests/core/text/scanner/test_core_text_scanner.odin
Normal file
@@ -0,0 +1,18 @@
|
||||
package test_core_text_scanner
|
||||
|
||||
import "core:testing"
|
||||
import s "core:text/scanner"
|
||||
|
||||
@test
|
||||
range_operator :: proc(t: ^testing.T) {
|
||||
data := "0x00..=0xff"
|
||||
h: s.Scanner
|
||||
s.init(&h, data, "string")
|
||||
h.flags = s.Odin_Like_Tokens - {.Skip_Comments}
|
||||
testing.expect(t, s.Int == s.scan(&h), "token should be Int")
|
||||
testing.expect(t, '.' == s.scan(&h), "token should be '.'")
|
||||
testing.expect(t, '.' == s.scan(&h), "token should be '.'")
|
||||
testing.expect(t, '=' == s.scan(&h), "token should be '='")
|
||||
testing.expect(t, s.Int == s.scan(&h), "token should be Int")
|
||||
testing.expect(t, s.EOF == s.scan(&h), "token should be EOF")
|
||||
}
|
||||
Reference in New Issue
Block a user