@@ -193,6 +193,52 @@ func TestJSONParser_AutoDetectSchema(t *testing.T) {
193193 })
194194}
195195
196+ func TestJSONParser_NumericValues (t * testing.T ) {
197+ mfs := testutil .NewFixtureFS (t , "fixtures/draft/numeric-values" , "/test" )
198+
199+ p := parser .NewJSONParser ()
200+ tokens , err := p .ParseFile (mfs , "/test/tokens.json" , parser.Options {
201+ SchemaVersion : schema .Draft ,
202+ })
203+
204+ if err != nil {
205+ t .Fatalf ("unexpected error: %v" , err )
206+ }
207+
208+ if len (tokens ) != 4 {
209+ t .Errorf ("expected 4 tokens, got %d" , len (tokens ))
210+ }
211+
212+ // Build lookup by name
213+ tokenByName := make (map [string ]string )
214+ for _ , tok := range tokens {
215+ tokenByName [tok .Name ] = tok .Value
216+ }
217+
218+ // Numeric $value fields must populate Token.Value as a string
219+ tests := []struct {
220+ name string
221+ expected string
222+ }{
223+ {"font-weight-regular" , "400" },
224+ {"font-weight-medium" , "500" },
225+ {"font-weight-bold" , "700" },
226+ {"opacity-half" , "0.5" },
227+ }
228+
229+ for _ , tt := range tests {
230+ t .Run (tt .name , func (t * testing.T ) {
231+ val , ok := tokenByName [tt .name ]
232+ if ! ok {
233+ t .Fatalf ("token %s not found" , tt .name )
234+ }
235+ if val != tt .expected {
236+ t .Errorf ("Token.Value = %q, want %q" , val , tt .expected )
237+ }
238+ })
239+ }
240+ }
241+
196242func TestJSONParser_SkipPositions (t * testing.T ) {
197243 mfs := testutil .NewFixtureFS (t , "fixtures/draft/simple" , "/test" )
198244 data , err := mfs .ReadFile ("/test/tokens.json" )
0 commit comments