Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hog): not now #27051

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions hogvm/__tests__/__snapshots__/stl.hoge
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
"startsWith", 2, 32, "abcdef", 33, 2, 33, 3, 2, "substring", 3, 2, "print", 2, 35, 31, 31, 32, "firstNonNull", 2,
"coalesce", 3, 32, "notNull", 2, "assumeNotNull", 1, 2, "print", 2, 35, 32, "", 2, "print", 1, 35, 32, "-- date --", 2,
"print", 1, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toYear", 1, 32, "2024-12-18T00:00:00Z", 2,
"toDateTime", 1, 2, "toMonth", 1, 2, "print", 2, 35, 2, "now", 0, 2, "toStartOfDay", 1, 2, "now", 0, 2, "toStartOfWeek",
1, 2, "print", 2, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toYYYYMM", 1, 2, "print", 1, 35, 32, "day",
33, 1, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 32, "day", 32, "2024-12-18", 2, "toDate", 1, 32, "day", 33, 5,
32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 2, "dateDiff", 3, 2, "print", 2, 35, 32, "day", 32,
"toDateTime", 1, 2, "toMonth", 1, 2, "print", 2, 35, 2, "now", 0, 2, "typeof", 1, 2, "print", 1, 35, 32,
"2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2, "toStartOfDay", 1, 32, "2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2,
"toStartOfWeek", 1, 2, "print", 2, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toYYYYMM", 1, 2, "print", 1,
35, 32, "day", 33, 1, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 32, "day", 32, "2024-12-18", 2, "toDate", 1,
32, "day", 33, 5, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 2, "dateDiff", 3, 2, "print", 2, 35, 32, "day", 32,
"2024-12-18T12:34:56Z", 2, "toDateTime", 1, 2, "dateTrunc", 2, 2, "print", 1, 35, 32, "2024-12-18", 2, "toDate", 1, 33,
3, 2, "addDays", 2, 2, "print", 1, 35, 33, 5, 2, "toIntervalDay", 1, 33, 2, 2, "toIntervalMonth", 1, 2, "print", 2, 35,
2, "today", 0, 2, "print", 1, 35, 32, "", 2, "print", 1, 35, 32, "-- json --", 2, "print", 1, 35, 32, "{\"a\":123.1}",
Expand Down
16 changes: 15 additions & 1 deletion hogvm/__tests__/__snapshots__/stl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
function upper (value) { return value.toUpperCase() }
function __x_typeof (value) {
if (value === null || value === undefined) { return 'null'
} else if (__isHogDateTime(value)) { return 'datetime'
} else if (__isHogDate(value)) { return 'date'
} else if (__isHogError(value)) { return 'error'
} else if (typeof value === 'function') { return 'function'
} else if (Array.isArray(value)) { if (value.__isHogTuple) { return 'tuple' } return 'array'
} else if (typeof value === 'object') { return 'object'
} else if (typeof value === 'number') { return Number.isInteger(value) ? 'integer' : 'float'
} else if (typeof value === 'string') { return 'string'
} else if (typeof value === 'boolean') { return 'boolean' }
return 'unknown'
}
function tuple (...args) { const tuple = args.slice(); tuple.__isHogTuple = true; return tuple; }
function today() {
const now = new Date();
Expand Down Expand Up @@ -522,7 +535,8 @@ print(coalesce(null, null, "firstNonNull"), assumeNotNull("notNull"));
print("");
print("-- date --");
print(toYear(toDateTime("2024-12-18T00:00:00Z")), toMonth(toDateTime("2024-12-18T00:00:00Z")));
print(toStartOfDay(now()), toStartOfWeek(now()));
print(__x_typeof(now()));
print(toStartOfDay(toDateTime("2024-12-18T11:11:11Z")), toStartOfWeek(toDateTime("2024-12-18T11:11:11Z")));
print(toYYYYMM(toDateTime("2024-12-18T00:00:00Z")));
print(dateAdd("day", 1, toDate("2024-12-18")), dateDiff("day", toDate("2024-12-18"), dateAdd("day", 5, toDate("2024-12-18"))));
print(dateTrunc("day", toDateTime("2024-12-18T12:34:56Z")));
Expand Down
3 changes: 2 additions & 1 deletion hogvm/__tests__/__snapshots__/stl.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ firstNonNull notNull

-- date --
2024 12
datetime
DateTime(1734480000.0, 'UTC') DateTime(1734307200.0, 'UTC')
202412
Date(2024, 12, 19) 5
DateTime(1734480000.0, 'UTC')
Date(2024, 12, 21)
{'__hogInterval__': true, 'value': 5, 'unit': 'day'} {'__hogInterval__': true, 'value': 2, 'unit': 'month'}
Date(2024, 12, 18)
Date(2024, 12, 19)

-- json --
123 null
Expand Down
3 changes: 2 additions & 1 deletion hogvm/__tests__/stl.hog
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ print(coalesce(null, null, 'firstNonNull'), assumeNotNull('notNull'))
print('')
print('-- date --')
print(toYear(toDateTime('2024-12-18T00:00:00Z')), toMonth(toDateTime('2024-12-18T00:00:00Z')))
print(toStartOfDay(now()), toStartOfWeek(now()))
print(typeof(now()))
print(toStartOfDay(toDateTime('2024-12-18T11:11:11Z')), toStartOfWeek(toDateTime('2024-12-18T11:11:11Z')))
print(toYYYYMM(toDateTime('2024-12-18T00:00:00Z')))
print(dateAdd('day', 1, toDate('2024-12-18')), dateDiff('day', toDate('2024-12-18'), dateAdd('day', 5, toDate('2024-12-18'))))
print(dateTrunc('day', toDateTime('2024-12-18T12:34:56Z')))
Expand Down
Loading