• 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

92.86
/json5/internal_types.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
priv struct ParseContext {
17
  mut offset : Int
18
  input : String
19
  end_offset : Int
20
}
21

22
///|
23
fn ParseContext::make(input : String) -> ParseContext {
24
  { offset: 0, input, end_offset: input.length() }
74✔
25
}
26

27
///|
28
priv type CharClass Array[(Char, Char)]
29

30
///|
31
fn CharClass::of(array : Array[(Char, Char)]) -> CharClass {
32
  CharClass(array)
3✔
33
}
34

35
///|
36
fn CharClass::contains(self : CharClass, c : Char) -> Bool {
37
  for left = 0, right = self._.length(); left < right; {
14✔
38
    let middle = (left + right) / 2
86✔
39
    let (min, max) = self._[middle]
40
    if c < min {
41
      continue left, middle
58✔
42
    } else if c > max {
28✔
43
      continue middle + 1, right
15✔
44
    } else {
45
      break true
13✔
46
    }
47
  } else {
48
    false
1✔
49
  }
50
}
51

52
///|
53
priv enum Token {
54
  Null
55
  True
56
  False
57
  Number(Double)
58
  String(String)
59
  LBrace
60
  RBrace
61
  LBracket
62
  RBracket
63
  Comma
64
  Colon
65
} derive(Eq, Show)
66

67
///|
68
priv struct StringBuilder {
69
  mut buffer : String
70
}
71

72
///|
73
fn StringBuilder::make() -> StringBuilder {
74
  { buffer: "" }
35✔
75
}
76

77
///|
78
fn add_string(self : StringBuilder, s : String) -> Unit {
UNCOV
79
  self.buffer = self.buffer + s
×
80
}
81

82
///|
83
fn add_substring(
84
  self : StringBuilder,
85
  s : String,
86
  start : Int,
87
  end : Int
88
) -> Unit {
89
  self.buffer = self.buffer + s.substring(start~, end~)
22✔
90
}
91

92
///|
93
fn add_char(self : StringBuilder, c : Char) -> Unit {
94
  self.buffer = self.buffer + c.to_string()
19✔
95
}
96

97
///|
98
fn to_string(self : StringBuilder) -> String {
99
  self.buffer
25✔
100
}
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