MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / run

Method run

xs/tools/unicode/strings.js:78–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76 return ranges;
77 }
78 run() {
79 let once = true;
80 let tool = this;
81 let singles;
82 let multiples;
83 let ids = [];
84
85 function testPropertyOfStrings(param) {
86 for (let string of param.matchStrings) {
87 const codePoints = [ ...string ].map((cp) => cp.codePointAt(0));
88 if (codePoints.length == 1) {
89 singles.push(codePoints[0]);
90 }
91 else {
92 multiples.push({ length:codePoints.length, bytes:string });
93 }
94 }
95 }
96 const directory = this.resolveDirectoryPath("../../../../test262/test/built-ins/RegExp/property-escapes/generated/strings");
97 const names = this.enumerateDirectory(directory);
98 for (let name of names) {
99 if (name.indexOf("negative") >= 0)
100 continue;
101 const path = this.joinPath({directory, name});
102 if (this.isDirectoryOrFile(path) != 1)
103 continue;
104 let buffer = this.readFileString(path);
105 buffer = buffer.replaceAll("/^\\p", "'");
106 buffer = buffer.replaceAll("$/v", "'");
107 try {
108 once = true;
109 singles = [];
110 multiples = [];
111 eval(buffer);
112 singles.sort((a, b) => {
113 return a - b;
114 });
115 multiples.sort((a, b) => {
116 if (a.length > b.length) return -1;
117 if (a.length < b.length) return 1;
118 return b.bytes.localeCompare(a.bytes);
119 });
120 let ranges = this.buildRanges(singles);
121 name = name.slice(0, -3);
122 ids.push(name);
123 this.reportRanges(name, ranges);
124 this.reportStrings(name, multiples);
125 ids.sort();
126 }
127 catch(e) {
128 }
129 }
130 this.reportNames(ids);
131 }
132}

Callers

nothing calls this directly

Calls 6

buildRangesMethod · 0.80
reportRangesMethod · 0.80
reportStringsMethod · 0.80
reportNamesMethod · 0.80
sliceMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected