• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / x / 301

10 Dec 2024 06:19AM UTC coverage: 85.204% (-2.6%) from 87.841%
301

Pull #78

github

web-flow
Merge b830031f4 into 91f0fdf48
Pull Request #78: feat: new package encoding

105 of 161 new or added lines in 3 files covered. (65.22%)

124 existing lines in 29 files now uncovered.

1169 of 1372 relevant lines covered (85.2%)

434.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/json5/util.mbt
1
// Copyright 2024 International Digital Economy Academy
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
///|
16
fn offset_to_position(input : String, offset : Int) -> Position {
17
  let mut line = 1
23✔
18
  let mut column = 0
19
  for i = 0; i < offset; i = i + 1 {
50✔
20
    let c = input[i]
50✔
21
    if c == '\n' {
UNCOV
22
      line += 1
×
23
      column = 0
24
    } else {
25
      column += 1
50✔
26
    }
27
  }
28
  return Position::{ line, column }
29
}
30

31
///|
32
fn invalid_char[X](ctx : ParseContext, shift~ : Int = 0) -> X!ParseError {
33
  let offset = ctx.offset + shift
22✔
34
  parse_error!(
35
    InvalidChar(offset_to_position(ctx.input, offset), ctx.input[offset]),
UNCOV
36
  )
×
37
}
38

39
///|
40
fn hex_digit_to_int(c : Char) -> Int {
41
  if c >= 'A' {
30✔
42
    (c.to_int() & (32).lnot()) - 'A'.to_int() + 10
16✔
43
  } else {
44
    c.to_int() - '0'.to_int()
14✔
45
  }
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc